Different ways to create Array in JavaScript

Photo by Caspar Camille Rubin on Unsplash

Array is very frequently used while working in JavaScript. In this article, we will see the different ways to create Array in JavaScript.

  1. Using Array function

It creates a new array with items passed as argument.

2. Using Array literal

An array literal is the easiest way to create a JavaScript Array.

3. Using new operator

It creates a new array with length

4. Using Spread operator

The spread operator was added to JavaScript in ES6 (ES2015).

5. Using Array.from

Find much more about JavaScript libraries/frameworks at jsonworld

JavaScript Developer | Blogger — Expert in NodeJS, Firebase, Angular, React