Why can't I concat an array reference in JavaScript? -
i have 2 arrays, 1 comes reference (parameter) function, , other created part of function - same scenario described here:
add 2 arrays without using concat method
i using push.apply() method per suggestion above, can please explain me, why can't use concat() merge 2 arrays if array sent function reference?
refer array.concat on mdn:
any operation on new array will have no effect on original arrays, , vice versa.
this makes behave differently array.push.apply will mutate original array object - return value of array.concat must used. otherwise, works explained in mdn link above.
Comments
Post a Comment