DEV Community

Mahipal Nehra for Decipher Zone

Posted on

Top JavaScript Array Methods

An array is one of the most widely recognized ideas of Javascript, which gives us plenty of potential outcomes to work with information put away inside. Mulling over that array is one of the most fundamental themes in Javascript which you find out about toward the start of your programming way.

In this article, I might want to show you a couple of stunts that you may not think about and which might be useful in coding! We should begin.

Full article source:

Top 13 useful JavaScript Array Tips for Developers

Here are the top 13 useful JavaScript array methods for developers.

*How to remove duplicates from an array

*How to change a particular value in an array

*How to use Map array without .map()

*To empty an array

*How to convert an array to an object

*How to fulfill an array with data

*How to merge arrays

*How to find the intersection of two arrays

*How to remove falsy values from an array

*How to get random value form the array

*How to reverse an array

*JavaScript's .lastIndexOf() method

*How to sum all the values in the array

1. How to remove duplicates from an array

It's a famous inquiry question about Javascript arrays, how to remove the exceptional qualities from Javascript array. Here is a snappy and simple answer for this issue, you can utilize another Set() for this reason. What's more, I might want to give both of you potential approaches to do it, one with .from() strategy and second with spread administrator (…).

var fruits = [“banana”, “apple”, “orange”, “watermelon”, “apple”, “orange”, “grape”, “apple”];

// First method
var uniqueFruits = Array.from(new Set(fruits));
console.log(uniqueFruits); // returns [“banana”, “apple”, “orange”, “watermelon”, “grape”]
// Second method
var uniqueFruits2 = […new Set(fruits)];
console.log(uniqueFruits2); // returns [“banana”, “apple”, “orange”, “watermelon”, “grape”]

2. How to change a particular value in an array

Full article source:

Top comments (1)

helenanders26 profile image
Helen Anderson

Hi there, Articles should not primarily be used for driving traffic to an article on another website. Please post the entire article here on DEV (if you have proper rights).