javascript iterate array of variables and reassign value to each variable
- by Shanison
Hi how should i iterate array of variables and reassign value to each variable. E.g in jQuery
function test(param1, param2) {
$.each([param1, param2], function (i, v) {
//check if all the input params have value, else assign the default value to it
if (!v)
v = default_value; //this is wrong, can't use v, which is value
}
}
How should I get the variable and assign new value in the loop?
Thank you very much!