When the variable foo is defined, why does the following code behave in a certain way?
var array = [].push(foo);
When executed, why does the output equal 1?
Based on my testing, the variable array simply returns the length of the array.
Therefore, if the code is changed to:
var array = [10,20].push(foo);
the value will then be 3.
Another question arises in regard to the initial intention of the code. Why doesn't the following code snippet behave as expected:
var array = [];
array.push(foo);
When array is output, why does it not display [foo] as anticipated?