Why cant I push inside an array and use it in a function argument in javascript? -


why b , c not identical in below code? order of statement execution in line number 2?

var = [1,2]; var b = new array(a.push(1)); //[undefined, undefined, undefined] var c = new array(a);         // [[1, 2, 1]] 

the .push() function returns new length of array, not array itself. thus, b initialized 3-element empty array because .push() returns 3 (after adding 1 end of array a).


Comments