Sometimes, we want to fix Cannot read property ‘push’ of undefined when combining arrays with JavaScript.
In this article, we’ll look at how to fix Cannot read property ‘push’ of undefined when combining arrays with JavaScript.
How to fix Cannot read property ‘push’ of undefined when combining arrays with JavaScript?
To fix Cannot read property ‘push’ of undefined when combining arrays with JavaScript, we should make sure we’re calling push on an array.
For instance, we write
const order = new Array();
order.push(a[n]);
to call order.push to append a new entry into the order array.
Conclusion
To fix Cannot read property ‘push’ of undefined when combining arrays with JavaScript, we should make sure we’re calling push on an array.
