Welcome to the fourteenth Easy JavaScript Tutorial, Beginner JavaScript Tutorial, part of Easy Programming! In this tutorial, we look at the various types of methods available in JavaScript.
Arrays are extremely powerful and the methods available will give your fingertips even more power. The methods available to you are:
Here are a few of the Array Methods available to you:
Name | Description |
---|---|
array.toString() | convert an array to a string |
array.join() | convert an array to a string but you can specify a separator |
array.pop() | remove the last element from the array (lifo) |
array.push() | add an element to the end (lifo) |
array.shift() | remove the first element from the array (fifo) |
array.unshift() | add an element in the beginning (fifo) |
array.splice() | add or remove new elements anywhere in the array |
array.slice() | create a new array with previous array data |
array.sort() | sort the array values in ascending order |
array.reverse() | sort the array values in descending order |
string.split() | split a string into an array |
array.forEach | Loop/iterate through array elements - tutorial covered in the Array.forEach tutorial |
To fork the fiddle and follow along: https://jsfiddle.net/easyjs/gzeamsry/
Remember to checkout the Resources section below for associated downloadable content, JSFiddle links, and other resources. Watch the video and follow along!