DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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: https://www.decipherzone.com/blog-detail/javascript-array

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: https://www.decipherzone.com/blog-detail/javascript-array

Top comments (1)

Collapse
 
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).

This post blew up on DEV in 2020:

js visualized

πŸš€βš™οΈ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! πŸ₯³

Happy coding!