JS_Part 12: Type of methods are available in JavaScript Array? How to use methods in Array?

Опубликовано: 27 Апрель 2021
на канале: Codenbox AutomationLab
109
6

#javaScript #array #methods
+Methods are in Array?
+Type of methods are available in JavaScript Array?
+How to use different methods in JavaScript Array?


▬▬▬▬▬▬ In this Video ▶️ ▬▬▬▬▬▬
An array is a special variable, which can hold more than one value at a time. So it used to store multiple values in a single variable. Arrays provide a lot of methods to make things easier as below:

//Converting arrays to String:
Arr.toString() –converts an array to a string of (comma separated) array values.

//Join arrays elements:
Arr.join() –joins all array elements into a string.
//Add/remove items:
Arr.push(..items) –adds item to the end
Arr.pop(..items) –extracts an item from the end
Arr.shift(..items) –extracts an item from the beginning
Arr.unshift(..items) –adds item to the beginning
Arr.splice(index..items) –adds new items to an array based on index position

//Merging (Concatenating) arrays:
Arr.concat()- method creates a new array by merging (concatenating) existing arrays

//Sorting & reversing an Array :
Arr.sort() –method sorts an array alphabetically
Arr.reverse() –method reverses the elements in an array/can be use to sort an array in descending order

//Searching in array:
Arr.indexOf(item, from) –looks for item starting from index from and returns the index where it was found, otherwise -1
Arr.lastIndexOf(item, from)- same, but looks for from right to left
Arr.includes(item, from)- looks for item starting from index from and returns true if found

▬▬▬▬▬▬ Useful Links 🛠 ▬▬▬▬▬▬
Blog ► http://codenboxautomationlab.com/​​
GitHub Repo ► https://github.com/codenbox​

▬▬▬▬▬▬ Connect with us 👋 ▬▬▬▬▬▬
~~~Subscribe to this channel, and press bell icon to get all updated videos on Selenium and Cypress Automation:
   / codenboxautomationlab  

~~~ Follow us on Facebook & Twitter to get more updates:
  / ​​  
  / codenboxteam​