node.js - Reducing the number of arguments passed to a function in node js -


i have written code, calls several callback functions 1 after other, thing there many arguments passed functions not code acceptability.

    validate.set(value1 , value2, value3, value4, value5, value6, value7, function(response){ some_other_function(value8, value9, value10, value11, value12, value13, function(response){  })   }) 

there many values getting passed in functions not good programming(maximum 5 variables must pass right) so, there way these arguments in other functions called)

ways thought : 1. constructing array or json body , sending. 2. creating separate module , retrieving them(but way doesn't goes functions getting values changeable, means retrieving values request sent node js , sending them in functions)

modify code , start using es6 feature rest parameters. might need t

function dosomething(value1, value2, ...values){     console.log(value1); // 1     console.log(value2); // 2     console.log(values); // [3,4,5,6] } dosomething(1,2,3,4,5,6); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -