Search

Blogs Blogs

Array Blogs

Newest Most Active

Arrays are an important part of javascript. There are situation where you may want to add more items to an array at run time. In order to add a new item to the end of an Array, we use the push() function.   .push() takes one or more parameters and pushes them to the end of the array   e.g   var arr = [1, 2, "three", 4, "hello"]; arr.push("good");   The resulting arr will now contain:   [1, 2, "three", 4, "hello", "good"]    You can also pass multiple item to .push(), e.g: arr.push("best", 4, "amazing");   I hope you now are now familiar with .push() function. In the next blog post, I will explain the pop() function.   Task: Consider the following array var fruits = ["apple", "banana", "orange"]; Add two more fruits to the fruits array...

Array Blogs RSS feed