Recently i was experimenting with array push()
method in javascript.
I created an array, and pushed the same array using push method.
var a=['hello', 4]
a.push(a)
the result was surprising, when i explored the array items in chrome console, there was infinite array produced. i want to know why this is happening. As the push()
method adds the element on last.
I was expecting this result
['hello, 4, ['hello',4]]
but the result was something else, here is the screenshot of chrome console problem screenshot, infinite inner arrays using push method in JavaScript