javascript - How do I assign a value to a variable stored in an array? -
for example:
var = b = c = null; var array = [a, b, c]; var value = 5; how assign value a using array, without having array[0] overwritten?
how assign value variable stored in array?
you can't.
i think have misconception here: javascript pass-by-value, i.e. array doesn't hold reference variable, holds value variable had @ moment array created.
when write [a, b, c] literally means "evaluate a, b , c , add values array". after array created, there no knowledge anymore values came from.
this makes sense, since same behavior if use literals or other expressions instead of variables: [1, 40 + 2, "foo"]. evaluates each expression , adds result array.
Comments
Post a Comment