- PUSH
The push() method adds new elements to the end of an array and
returns the new length.
const arr = ["The", "coding"];
arr.push("Master");//["The", "Coding", "Master"]
- SLICE
The slice() method selects a part of an array and returns the new
array.
const arr = ["The", "Coding", "Master"];
arr.slice(1,2);//["Coding", "Master"]
- TOSTRING
The toString() method converts an array to a string and returns
the result.
const arr = ["The", "Coding", "Master"];
arr.tostring();//"The, Coding, Master"
- SHIFT
The shift() method removes the first element of the array and returns that element.
const arr = ["The", "Coding", "Master"];
arr.shift();//["Coding", "Master"]
- MAP
The map() method creates a new array with the result of calling a function of every array element.
const arr = [1, 4, 9, 16];
arr.map( x => x * 2);//[2, 8, 16, 32]
- POP
The pop() method removes the last element of an array and returns that element.
const arr = ["The", "Coding", "Master"];
arr.pop();///["The", "Coding"]
- FILTER
The filter() method creates an array filled with all array elements that pass a test (provided as a function).
const arr = ["The", "Coding", "Master"];
arr.filter(word => word.length > 3);//["Coding", "Master"]
- INCLUDES
The includes() determines whether an array contains s specified
element.
const arr = ["The", "Coding", "Master"];
arr.includes("Coding");//true
Top comments (0)