array[0]
array[array.length-1]
array.push(val)
can push multiple valuesarray.unshift(val)
array.pop()
returns the last item from an array and removes itarray.shift()
returns the first item from an array and removes it.join()
.concat()
indexOf()
1for( var i=0; i<arr.length; i += 1) {
2 console.log(arr[i]);
3}
Do note that using for
loops are the ancient way of doing things. You should be using cool higher order functions like .map
and .reduce