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!
Maybe I didn't describe my question clearly. My intention is to iterate array of variables, not array of strings.
var variable_1 = "hello";
var variable_2 = null;
i want to iterate [variable_1, variable_2], and check each value, if variable_2 is null, so i will assign the default value to variable_2 to change the value.