10 Unpopular Javascript Array Methods
Tags: javascript, webdev, beginners, tutorial
Published: 2019-11-12 08:35:01

---
title: 10 Unpopular Javascript Array Methods
published: true
description: 
canonical_url: https://dev.to/desoga/10-unpopular-javascript-array-methods-4dkf
tags: javascript, webdev, beginners, tutorial
cover_image: https://res.cloudinary.com/dz4tt9omp/image/upload/v1573401124/javascript_array.png
---

> _Someone is sitting in the shade today because someone planted a tree a long time ago.
> -Warren Buffett_


## Introduction

Arrays in **javascript** are variables which can hold more than one value at a time.It is used to store a list of elements which can be retrieved at any point in time.

In javascript, we are provided with lots of custom array methods. Today we will be looking at those array methods that are not used as much as the popular ones like: **map()**, **filter()** and **reduce()**.

The question is, how do I know which array methods are popular or not? I was able to do that through a tool called **Google Trends**. 

**Google Trends** is a website created by Google that analyzes the popularity of top search queries in Google Search across various regions and languages. The website uses graphs to compare the search volume of different queries over time.


Now let's get started with the first unpopular method in javascript.


# **1.**     **Array.prototype.entries()**

### Definition

The entries() method is a custom javascript method that helps to get a new array, which returns a new array iterator as key|value pairs.


### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573418969/entries.png" alt="entries graphical data">

Analysis of the query results from the image above shows that, **Array.prototype.entries()** is not as used compared to other array methods like *map*, *filter* *and reduce*

### Code Example / Usage

{% gist https://gist.github.com/desoga10/77504cbc243e6e81f646fbffdb2e1174 %}


### Result
`
0,Nigeria
1,Usa
2,France
3,Brazil
`

### Summary

From our result, using the *array.entries()* method, we were able to get the key value pair for each index of the array.


# **2.**     **Array.prototype.copyWithin()**

### Definition

The *copyWithin()* method in javascript copies part of an array, within the same array without adding or subtracting from the original array. That is, it changes the position of elements within an array without modifying it's length.


### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573422340/copyWithin.png" alt="entries graphical data">

The query result shows that the **Array.prototype.copyWithin()** method shows that the data for amount of time it's been queried is insufficient to be plotted into a graph, which is why it's on this list.

### Code Example / Usage

{% gist https://gist.github.com/desoga10/f16bd91076dc819729539e629d8c8d9a %}

### Result
`4 5 6 4 5 6 7 8 9 10
`
### Summary

our result above shows that the *copyWithin* method placed at position 0, the index between 3 and 6, while the length of our array remains the same.


# **3.**     **Array.prototype.every()**

### Definition

The *every()* method checks if all the elements in an array meets up with the condition provided by a specific function. 

This method returns a Boolean value depending on the condition set by a particular function.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573424126/every.png" alt="entries graphical data">

The graph above shows that the query results of **Array.prototype.every()** is not as used compared to other array methods like *map*, *filter* *and reduce* which is why it's on this list.


### Code Example / Usage

{% gist https://gist.github.com/desoga10/41745264107da201f6c0c350c1aed0fc %}

### Result
`true
`

### Summary

The example above checks if all the numbers in the *figure* array are either equals to, or greater than 18, which is why it returned the Boolean value *true*


# **4.**     **Array.prototype.fill()**

### Definition

The **Array.fill()** method is used to fill the elements in an array with a given static value. It takes in three parameters, the *value* which is required and *start* and *end* which are both optional.

The *start* and *end* parameters helps us to specify which position to fill in the array.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573474285/fill.png" alt="entries graphical data">


### Code Example / Usage

{% gist https://gist.github.com/desoga10/6f91d02919ef9b3a4121f6231e150fa0 %}

### Result

`Array [1, 5, 5, 5, 5, 5, 5]
 Array [6, 6, 6, 6, 6, 6, 6]
`
### Summary

The first *console.log()* specifies two parameters, which is that the entire array should be filled with the number 5 from the index position of 1.

The second *console.log()* fills the entire array with the number 6, because there was no start or end parameter specified.

# **5.**     **Array.isArray()**

### Definition

The **isArray()** method helps to primarily check if an object is actually an array. It returns a Boolean value, that is, *true* if an object is an array and *false* if it's otherwise.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573475995/isArray.png" alt="entries graphical data">

### Code Example / Usage

{% gist https://gist.github.com/desoga10/03e519cc3dffaa9f716f631d55cb2c58 %}

### Result
`true
 false
 false
`

### Summary

Nothing to explain here really, it's obvious from the code above that the first example is an array while the others are not arrays. Hence the reason we got our results as Boolean(true, false, false).

# **6.**     **Array.prototype.keys()**

### Definition

The **keys()** method helps to return a new Array Iterator Object containing the keys for each position of index in an array.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573478484/keys.png" alt="entries graphical data">


### Code Example / Usage

{% gist https://gist.github.com/desoga10/a6c33675e7880ad5834cc9854cd876fe %}

### Result
`0
 1
 2
 3
 4
`
### Summary

We created an array of countries and then we called the *keys()* method. Looping through each key we were able to get an index for each member of the array.

# **7.**     **Array.prototype.lastIndexOf()**

### Definition

The **lastIndexOf()** method searches through an array for a specified item and then return it's position.

The array is searched backwards, if no position is specified. If the given element is not found, it returns an index of **-1**.

It can take two parameters (*array.lastIndexOf(item, start)*), *item* and *start*.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573483002/lastIndexOf.png" alt="entries graphical data">

### Code Example / Usage

{% gist https://gist.github.com/desoga10/8f47e20e8a867ee5e702ebf9f48890ba %}

### Result
`0
 1
`
### Summary

The result of the first **console.log();** returned **o** because, we used the start parameter to specify the count to start from the second item of the array.

# **8.**     **Array.prototype.reduceRight()**

### Definition

The **reduceRight()**method reduces the length of an array to a single value.

The method applies a function against an accumulator and each value of the array from right to left.
 
### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573485076/reduceRight.png" alt="entries graphical data">

### Code Example / Usage

{% gist https://gist.github.com/desoga10/dc34a38b7debc837dc4611e75b4af7c3 %}

### Result
`-500
`
### Summary

The numbers in our array are subtracted from the right, giving us the value *-500* in the process.

# **9.**     **Array.prototype.reverse()**

### Definition

The **reverse()** method simply reverses the order of an array. That is, the first item of an array becomes the last and vice versa.

It is worthy to note that this method will also change the order of the original array.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573486184/reverse.png" alt="entries graphical data">

### Code Example / Usage

{% gist https://gist.github.com/desoga10/67e1d755f7e9199e3f445464ef0fdec0 %}

### Result
`Mars
 Earth
 Venus
 Mercury
`
### Summary

Using the *reverse()* method, we were able to reverse the order of the elements in the array.

# **10.**     **Array.prototype.valueOf()**

### Definition

This method returns the original array without modifying it in any way.
It is the default method of an array object.

### Search Query Statistics

<img src="https://res.cloudinary.com/dz4tt9omp/image/upload/v1573488389/valueOf.png" alt="entries graphical data">

### Code Example / Usage

{% gist https://gist.github.com/desoga10/93192273a43a649cabbb08321f280de1 %}

### Result
`Belgium,Sweden,Kuwait,Japan
`


To get more free content on web development, subscribe to my newsletter:
<a href="http://eepurl.com/gZ-jJH" target="_blank">here</a>