Skip to content

JavaScript multidimensional array push value | Code

  • by

Use the push() method to add one or more elements to the end of a multidimensional array in JavaScript. This method returns the new length of the array.


JavaScript multidimensional array push

A simple example code will add it to the end of the array.

<!DOCTYPE html>

    var z = new Array(7, 8, 9);
    var a = new Array(
      [1, 2, 3],
      [4, 5, 6]




JavaScript multidimensional array push

On ES6 you can use the spread operator (...) as follows:

    arrayA = [
    [1, 2, 3],
    [4, 5, 6]

    arrayB = [7,8,9];

    arrayA = [...arrayA, ...[arrayB]];

Comment if you have any doubts or suggestions on this JS Array topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *