Push onto array argument in javascript -


i have following function:

function where(arr, num) {   return arr.push(num); }  where([40, 60], 50); // returns 3 

i expecting return [40,60,50] returns 3.

thanks help.

the documentation states array.prototype.push() returns length of array. need push new number , return array.

function where(arr, num) {   arr.push(num);   return arr; }  myarray = where([40, 60], 50); // myarray === [40, 60, 50] 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -