Sometimes, we want to push to multidimensional array with JavaScript.
In this article, we’ll look at how to push to multidimensional array with JavaScript.
How to push to multidimensional array with JavaScript?
To push to multidimensional array with JavaScript, we call push with the array.
For instance, we write
const valuesToPush = Array();
valuesToPush[0] = productID;
valuesToPush[1] = itemColorTitle;
valuesToPush[2] = itemColorPath;
cookieValues.push(valuesToPush);
to create the valuesToPush array with some values.
Then we call push on the cookieValues array to append the valuesToPush array with push.
Conclusion
To push to multidimensional array with JavaScript, we call push with the array.