By definition, the push() method returns the new length
property of the object upon which the method is called.
The new length property of the object upon which the method was
called.
Here,
a.concat(b) //returns an `array`. But wait, the statement still has a method chained,
//and to be evaluated.
(returned array).push('e'); // the chained push() is invoked on the returned array.
which in turn returns the length
of the newly formed array.
So the final return value of the statement is the length
of the array, which is stored in the c
variable.
To capture the returned array
by the concat()
operation, you can modify your code to break down the chained methods into multiple statements, as below:
var c = a.concat(b);
c.push('e');
console.log(c) // prints the array content.