Today I learnt about calling a function within a function and arrays. An array is like a container that can hold more than one value at the same time. It could be an ordered list of items, composite data types or complex data types. This differentiates it from a variable that can just hold a value at a time.
let card = [“firstNumber” ,”secondNumber”] console.log(card)
The output will be
To access an array, you do this
Accessing an array starts at zero not one.
Arrays have their own built in methods. Methods can be described as functions on an object. The commonly known ones are;
This is used to determine the number of elements in an array
card.length // This will return two as there are two elements in the card array.
Concat is used to combine two arrays and return a combined array.
cars =[‘ferrari’, ‘Lamboghini’] card.concat(cars)
This will return [“firstNumber”, “secondNumber”,’ferrari’,’Lamboghini’]
This is to add an element to the array
newCard =”ThirdNumber” card.push(newCard)
This will add the new element “thirdNumber” into the array.
This is to remove an element from the array
This removes the 'newCard' element from the array.
Top comments (2)
Don't for get multidimentional arrays:
arrays, within an array.
let activities = [
['Play Game', 1],
I will not😃🤭. Thank you.