Web Development

The Complete JavaScript Array Methods guide

This is a complete JavaScript Array Methods guide. In this series I will take you through all of JavaScript Array Methods.

Welcome to the complete JavaScript Array Methods guid. In this series I will take you through all of JavaScript Array Methods, like:

  • concat() method
  • every() method
  • fill() method
  • filter() method
  • find() method
  • findIndex() method
  • forEach() method
  • from() method
  • map() method
  • includes() method
  • indexOf() method
  • isArray() method
  • join() method
  • reduce() method
  • sort() method
  • reverse() method
  • push & pop() method
  • unshift & shift() method
  • splice() method
  • some() method

JavaScript Concat Method

Description

In this video you will learn about the concat array method.

The concat() method is used to join two or more arrays.
This method does not change the existing arrays, but returns a new array, containing the values of the joined arrays.

concat.js Code:

const person = ["First Name", "Last Name"];
const info = ["Email", "Age", "Address"];

const personalInfo = person.concat(info);

console.log(personalInfo);

const addressDetails = personalInfo.concat("City", "Street");
console.log(addressDetails);

JavaScript every() method

The every() method checks if all elements in an array pass a test (provided as a function).The every() method executes the function once for each element present in the array.

If it finds an array element where the function returns a false value, every() returns false (and does not check the remaining values). Overwise If no false occur, every() returns true

every.js Code:

 const ages = [32, 33, 16, 40];

  function checkAge(age) {
    return age >= 10;
    // return age <= 39;
    // return age >= 18;
  }

  console.log(ages.every(checkAge));

JavaScript fill() method

 The fill() method fills the specified elements in an array with a static value.

concat.js Code:

 const fruits = ["Banana", "Orange", "Apple", "Mango"];
  console.log(fruits);

  fruits.fill("Kiwi");
  console.log(fruits);

  array.fill(value, start, end)

  fruits.fill("Apple", 1, 3);
  console.log(fruits);

Note: this method overwrites the original array. You can also specify the position of where to start and end the filling. If not specified, all elements will be filled.

JavaScript filter() method- coming 14 Jun 2021

The filter() method creates an array filled with all array elements that pass a test (provided as a function).

concat.js Code:

console.log("filter()");

const ages = [32, 33, 16, 40];

console.log(ages.filter(checkAdult));

function checkAdult(array) {
  let filterBy = array.age > 18;
  return filterBy;
}

const friends = [
  { name: "Arabella", age: 20 },
  { name: "Carina", age: 12 },
  { name: "Laura", age: 16 },
];

console.log(friends.filter(checkAdult));

 Note: filter() does not execute the function for array elements without values and filter() does not change the original array.

JavaScript find() method- coming 16 Jun 2021

JavaScript findIndex() method- coming 18 Jun 2021

JavaScript forEach() method- coming 21 Jun 2021

JavaScript from() method- coming 23 Jun 2021

JavaScript map() method- coming 25 Jun 2021

JavaScript includes() method- coming 28 Jun 2021

JavaScript indexOf() method- coming 30 Jun 2021

JavaScript isArray() method- coming 02 Jul 2021

JavaScript join() method- coming Jul 2021

JavaScript reduce() method- coming Jul 2021

JavaScript sort() method- coming Jul 2021

JavaScript reverse() method- coming Jul 2021

JavaScript push & pop() method- coming Jul 2021

JavaScript unshift & shift() method- coming Jul 2021

JavaScript splice() method- coming Jul 2021

JavaScript some() method- coming Jul 2021


For more information about JavaScript get the Complete Modern JavaScript Course NOW and become a javascript developer

https://volere.life/web-development/web-dev-courses/

Modern JavaScript and NodeJS from Beginner to Advanced

Popular course:

https://www.udemy.com/course/30-html-css-javascript-projects-in-30-days-for-beginners/?couponCode=APR2021

30 HTML, CSS & JavaScript projects in 30 Days for Beginners

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: