Search

Blogs Blogs

Javascript 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...

Arrays provide a way to store multiple pieces of information in a single thing. An array is basically a list of values: numbers, strings, boolean values or even other arrays or objects!   Loops are a way of repeating code -- they're very handy for repetitive tasks. Loops are frequently used to cycle through an array and perform an action on each item in the array.

Javascript Blogs RSS feed