+ 3

How to create an array in JS

I'm stuck somewhere. I want to store all items in my list in one variable (var) using JavaScript. I need help please.

7th Apr 2021, 12:34 AM
Zico
Zico - avatar
4 Answers
+ 5
Hi Ryan Zico Please note that how to create an Array is available in course of JavaScript, please view it! Array in Js -> https://www.sololearn.com/learning/1239/ https://www.sololearn.com/learn/JavaScript/1239/?ref=app
7th Apr 2021, 12:44 AM
Abhiyantā
Abhiyantā - avatar
+ 3
One very simple and commonly used way is with square brackets. This is called an the literal notation. var myList = [] This will create an empty array. You can add items to it using various methods like push or using the index number. If you want to create an array with items from the start, you can do this. var myList = ["first", "second"]
7th Apr 2021, 12:44 AM
CamelBeatsSnake
CamelBeatsSnake - avatar