My intention is is to get an array of arrays. i.e [['item','C']]. I'm unable to figure out why the below code always produces [2] ? Could someone please help?
function arrayOfArrays()
{
return [].concat([].push('item','C'))
}
console.log(arrayOfArrays());
console.log(arrayOfArrays());
Array#push returns:
The new length property of the object upon which the method was called.
Whereas, Array#concat returns:
A new Array instance.
Try this instead:
console.log( [[].concat('item','C')] );
// OR
console.log( [ ['item','C'] ] );