𝗔𝗿𝗿𝗮𝘆 𝗠𝗲𝘁𝗵𝗼𝗱𝘀 𝗜𝗻 𝗝𝗮𝘃𝗮𝘀𝗰𝗿𝗶𝗽𝘁

You need to manage data efficiently in JavaScript. Arrays help you store lists of information. Use these methods to control your data.

Array Length The length property tells you how many items are in an array. You use it to check size or set a new limit.

  • fruits.length returns the count.
  • Changing the length removes items from the end.

Converting to Strings You often need to turn an array into text.

  • toString() creates a string with commas.
  • join(" separator ") creates a string with your chosen character.

Accessing Elements You must grab specific items from your list.

  • fruits[2] gets the third item.
  • fruits.at(2) also gets the third item.

Adding and Removing Items Manage the ends of your array with ease.

  • push() adds an item to the end.
  • pop() removes the last item.
  • unshift() adds an item to the start.
  • shift() removes the first item.

Updating Items You change items using their index number.

  • Indexes start at 0.
  • fruits[0] = "Kiwi" replaces the first item.
  • fruits[fruits.length] = "Kiwi" adds an item to the end.

Source: https://www.w3schools.com/js/js_array_methods.asp Full post: https://dev.to/madhanraj/array-methods-in-javascript-38n8