How to declare arrays and store data permanently in them? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to declare arrays and store data permanently in them?

I'm new to js. I'm creating a to do list where the entries are stored in an array. data in it should be able to be modified and deleted and stored permanently. is there a better way to do this or can I get some examples of declaring an array and modifying it

30th Jul 2017, 8:30 AM
Mashan Shaluka1
Mashan Shaluka1 - avatar
2 Answers
+ 10
There are three different ways in JavaScript to declare arrays. All can be used to store data (permanently or temporarily). Examples... • First method : var courses = new Array("HTML", "CSS", "JS"); • Second Method : var courses = new Array(3);  courses[0] = "HTML";  courses[1] = "CSS";  courses[2] = "JS"; • Third method : var courses = ["HTML", "CSS", "JS"]; While many programming languages support arrays with named indexes (text instead of numbers), called associative arrays, JavaScript does not.  However, you still can use the named array syntax, which will produce an object. 
30th Jul 2017, 8:47 AM
Dev
Dev - avatar
0
thank you @dayve
30th Jul 2017, 8:54 AM
Mashan Shaluka1
Mashan Shaluka1 - avatar