Hi and welcome to my blog and first blog post! Here you can follow my learning journey to become a web developer. I recently got accepted to the Front-End developer program at mediainstitutet here in Sweden. So I quitted my full-time job to follow my dream.
What is an Array and how to create one?
An array is an ordered list of values and each value has an index starting from zero. An array can store numbers, strings, and booleans.
There are two ways to declare an array.
let array = [ ] // method 1
let array = new array() // method 2
I prefer the first method.
How to add elements into an array
push is probably the most used array method.
push is used to add new elements to the end of an array and then it returns the new length of the array.
unshift add one or more elements to the beginning of an array and returns the new length of the array.