Lawrence  Lesch

Lawrence Lesch


8 JavaScript Array Methods You Should Know

Array methods in JavaScript you need to know with examples.

Arrays form an integral part of almost any programming language. Having an understanding of arrays is very essential in uncovering the concepts of programming.

According to  Wikipedia, an array can be defined as a data structure consisting of a collection of elements, each identified by at least one array index or key. An array is stored such that the position of each element can be computed from its index tuple by a mathematical formula.

In this article, we are going to look at JavaScript array methods and how they can be used.

In simple terms, an array is just a variable with the capability of holding more than one value at a given time.

Also to be noted is that almost all the major browsers support these array methods.

map() method

filter() method

find() method

forEach() method

some() method

every() method

reduce() method

includes() method

#computer-science #arrays #javascript #coding

What is GEEK

Buddha Community

8 JavaScript Array Methods You Should Know
Terry  Tremblay

Terry Tremblay


Fill and Filter in Array in JavaScript

By the word Array methods, I mean the inbuilt array functions, which might be helpful for us in so many ways. So why not just explore and make use of them, to boost our productivity.

Let’s see them together one by one with some amazing examples.


The _fill()_ method changes all elements in an array to a static value, from a start index (default _0_) to an end index (default _array.length_). It returns the modified array.

In simple words, it’s gonna fill the elements of the array with whatever sets of params, you pass in it. Mostly we pass three params, each param stands with some meaning. The first param value: what value you want to fill, second value: start range of index(inclusive), and third value: end range of index(exclusive). Imagine you are going to apply this method on some date, so that how its gonna look like eg: array.fill(‘Some date’, start date, end date).

NOTE: Start range is inclusive and end range is exclusive.

Let’s understand this in the below example-

//declare array
var testArray = [2,4,6,8,10,12,14];


When you run this code, you gonna see all the elements of testArray will be replaced by 'A' like [“A”,"A","A","A","A","A","A"].

#javascript-tips #array-methods #javascript-development #javascript #arrays

Lowa Alice

Lowa Alice


JavaScript Arrays Tutorial. DO NOT MISS!!!

Learn JavaScript Arrays

📺 The video in this post was made by Programming with Mosh
The origin of the article:
🔥 If you’re a beginner. I believe the article below will be useful to you ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner
⭐ ⭐ ⭐The project is of interest to the community. Join to Get free ‘GEEK coin’ (GEEKCASH coin)!
☞ **-----CLICK HERE-----**⭐ ⭐ ⭐
Thanks for visiting and watching! Please don’t forget to leave a like, comment and share!

#arrays #javascript #javascript arrays #javascript arrays tutorial

Rose Lancy

Rose Lancy


9 Must Know JavaScript Array Methods

Arrays are one of the most common things that you’re going to use as a programmer. So, I’m going to explain nine JavaScript array methods that are going to make your life so much easier and more enjoyable.

To get started I just have an array of items, that we’re going to use for all these different array methods. Without wasting much time, let’s dive deep in to the pool of arrays (wink…)

const arrayItems = [
  {name: 'cheese cake', price: 25},
  {name: 'ham burger', price: 30},
  {name: 'cheesy tacos', price: 20},
  {name: 'beef burito', price: 18},
  {name: 'maxican chille rice', price: 15},
  {name: 'hot chocolate', price: 12},
  {name: 'apple frudge', price: 28},
  {name: 'chicken lassagna', price: 35},

filter() method

So let’s assume that we want to get all the items in this list that are less than or equal to 26 dollars of price. All we need to use is the filter method to filter out everything that’s under 26 dollars. So, let’s just say that, we have a variable which is going to be filteredItems. The filter method just takes a single function which is going to have one parameter.

const filteredItems = arrayItems.filter((item) => {
  return item.price <= 26;

#web-development #javascript #arrays #array-methods

Tanya  Shields

Tanya Shields


Learn Arrays And Array Methods in JavaScript

In JavaScript, an array is a data structure that contains list of elements which store multiple values in a single variable. The strength of JavaScript arrays lies in the array methods. Array methods are functions built-in to JavaScript that we can apply to our arrays — Each method has a unique function that performs a change or calculation to our array and saves us from writing common functions from scratch.
In this video we are going to learn arrays and array methods like sort(), reverse(), join(), split(), pop(), push(), shift(), unshift(), toString(), delete array, etc…

#javascript #arrays #array methods #programming

Shahab Uddin

Shahab Uddin


JavaScript array() methods, every JavaScript developer must know

1. push() method allows us to add one or more item at the end of an array.

let numbers = [1,2,3,4,5];
numbers.push(6); // Adding 6 at the end of the array
//Output: [1,2,3,4,5,6]

2. pop() method allows us to remove the item from the end of an array.

let numbers = [1,2,3,4,5];
numbers.pop(); // Removing last item from the array
//Output: [1,2,3,4]

3. shift() method allow us to remove an item from the front of the array

let numbers = [1,2,3,4,5];
numbers.shift(); // Removing the first item of the array
//Output: [2,3,4,5]

4. unshift() method allow us to add new items at the front of the array

let numbers = [1,2,3,4,5];
numbers.unshift(0); // Adding ‘0’ at the beginning of the array
//Output: [0,1,2,3,4,5]

5. forEach() method will help you to iterate over array’s items.

let numbers = [1, 2, 3, 4, 5];
numbers.forEach(item => {
	// Let's itrate the given array items and add 1 to each item.
    console.log(item + 1); 

6. includes() method return booleans to check either your array length includes the specific item passed in the method or not.

let numbers = [1, 2, 3, 4, 5];
//Output: false
//Output: true

7. filter() method creates a new array with a subset of elements of the original array.

Lets create an array object ‘names’ to apply filter()

let names = [
    {name: 'Shahab', age: 35},
    {name: 'Ibaad', age: 10},
    {name: 'Ayaan', age: 30},
    {name: 'Hamad', age: 20},
    {name: 'Pari', age: 22}
// Filtering names data by age > 10;
let filterd_items = names.filter(item => item.age > 10);

// Output:
0: {name: "Shahab", age: 35}
1: {name: "Ayaan", age: 30}
2: {name: "Hamad", age: 20}
3: {name: "Pari", age: 22}

8. sort() method allows us to sort data and return the elements after changing the positions of the elements in the original array.
The sort() method sorts the array elements in ascending order by default.

let numbers = [1, 5, 2, 0, 40, 3, 10 ];
//Output:  [0, 1, 10, 2, 3, 40, 5]

Look at the above output given by sort() method and the output is not as per expected,
To solve this issue, we need to pass a comparison function to the sort() method.


numbers.sort((a,b) => {
    if(a > b) return 1;
    if(a < b) return -1;
    return 0;
//Output: [0, 1, 2, 3, 5, 10, 40]

9. splice() method allows us to delete items in an array, to get result we have to pass two arguments to the splice() method.



let numbers = [1,2,3,4,5];
let deletedNumbs = numbers.splice(0,2);

//The original numbers array now contains only 3 items. i.e: 3,4,5
console.log(numbers); //  [3,4,5]

The new deletedNumbs array contains the deleted items from the original array
console.log(deletedNumbs); // [1, 2]

10. map() method take an array, manipulate its elements, and return a new array by calling the provided function in every element.


let numbers = [1,2,3,4,5];
Let's multiply each item and get the output doubled
let output = => item * 2)
//Output: [2, 4, 6, 8, 10]

#javascript #array #methods #arrowfunction