Creates
myFavoriteNumbers
array
let myFavoriteNumbers = [5, 14, 16, 18]
Adds new item
22
to the array
myFavoriteNumbers.push(22)
Adds the array as a new item to the
myFavoriteNumbers
array
myFavoriteNumbers.push([23, 24])
Adds the object to the array as new item
myFavoriteNumbers.push({firstNumber: 25, secondNumber: 26})
Adds the function to the array as new item
myFavoriteNumbers.push(function(){console.log('I am fired!')})
Adds new string item to the array
myFavoriteNumbers.push('27')
Let's fire the function that we added as an item
myFavoriteNumbers[7]()
After running the function the result will be:
I am fired!