concat(arr1,[...])// Joins two or more arrays, and returns a copy of the joined arrayscopyWithin(target,[start],[end])// Copies array elements within the array, to and from specified positionsentries()// Returns a key/value pair Array Iteration Objectevery(function(currentval,[index],[arr]),[thisVal])// Checks if every element in an array pass a testfill(val,[start],[end])// Fill the elements in an array with a static valuefilter(function(currentval,[index],[arr]),[thisVal])// Creates a new array with every element in an array that pass a testfind(function(currentval,[index],[arr]),[thisVal])// Returns the value of the first element in an array that pass a testfindIndex(function(currentval,[index],[arr]),[thisVal])// Returns the index of the first element in an array that pass a testforEach(function(currentval,[index],[arr]),[thisVal])// Calls a function for each array elementfrom(obj,[mapFunc],[thisVal])// Creates an array from an objectincludes(element,[start])// Check if an array contains the specified elementindexOf(element,[start])// Search the array for an element and returns its positionisArray(obj)// Checks whether an object is an arrayjoin([seperator])// Joins all elements of an array into a stringkeys()// Returns a Array Iteration Object, containing the keys of the original arraylastIndexOf(element,[start])// Search the array for an element, starting at the end, and returns its positionmap(function(currentval,[index],[arr]),[thisVal])// Creates a new array with the result of calling a function for each array elementpop()// Removes the last element of an array, and returns that elementpush(item1,[...])// Adds new elements to the end of an array, and returns the new lengthreduce(function(total,currentval,[index],[arr]),[initVal])// Reduce the values of an array to a single value (going left-to-right)reduceRight(function(total,currentval,[index],[arr]),[initVal])// Reduce the values of an array to a single value (going right-to-left)reverse()// Reverses the order of the elements in an arrayshift()// Removes the first element of an array, and returns that elementslice([start],[end])// Selects a part of an array, and returns the new arraysome(function(currentval,[index],[arr]),[thisVal])// Checks if any of the elements in an array pass a testsort([compareFunc])// Sorts the elements of an arraysplice(index,[quantity],[item1,...])// Adds/Removes elements from an arraytoString()// Converts an array to a string, and returns the resultunshift(item1,...)// Adds new elements to the beginning of an array, and returns the new lengthvalueOf()// Returns the primitive value of an array
functionsquare(arr){const newArr = arr.map(x=> x * x );return newArr ;//if you find this answer is useful ,//upvote ⇑⇑ , so can the others benefit also . @mohammad alshraideh ( ͡~ ͜ʖ ͡°)
let dailyActivities =['sleep','work','exercise']let newRoutine =['eat'];// sorting elements in the alphabetical order
dailyActivities.sort();console.log(dailyActivities);// ['exercise', 'sleep', 'work']//finding the index position of stringconst position = dailyActivities.indexOf('work');console.log(position);// 2// slicing the array elementsconst newDailyActivities = dailyActivities.slice(1);console.log(newDailyActivities);// [ 'sleep', 'work']// concatenating two arraysconst routine = dailyActivities.concat(newRoutine);console.log(routine);// ["exercise", "sleep", "work", "eat"]
//ADD ELEMENTS//PUSH - adds elements to the END OF ARRAYconst friends =["Zizi","Ioseb","Maiko"];const newLength = friends.push("Karina");console.log(friends);//["Zizi", "Ioseb", "Maiko"]console.log(newLenght);//["Zizi", "Ioseb", "Maiko", "Karina"]//UNSHIFT - add elements to BEGINNING OF THE ARRAY
friends.unshift("Baqso");console.log(friends);//["Baqso", "Zizi", "Ioseb", "Maiko", "Karina"]//REMOVE ELEMENTS//POP - removes LAST ELEMENT FROM ARRAY
friends.pop();//["Karina"]//returns removed elementconst popped = friends.pop();console.log(popped);//["Karina"]console.log(friends);//["Baqso", "Zizi", "Ioseb", "Maiko"]//shift - Removes FIRST ELEMENT FROM THE ARRAY
friends.shift();//["Baqso"]console.log(friends);//["Zizi", "Ioseb", "Maiko"]//indexOf - Tells the position of the element in the ARRAYconsole.log(friends.indexOf("Zizi"));//0//if we write the element which is not in the ARRAY we get : -1console.log(friends.indexOf("zizi"));//-1, we need to write in CamelCase//includes - modern method of indexOf//includes - testing with STRICT EQUALITYconsole.log(friends.includes("Zizi"));//true