Open In App

JavaScript Array from() Method

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The JavaScript Array from() method returns an Array object from any object with a length property or an iterable object. 

Syntax : 

Array.from(object, mapFunction, thisValue)

Parameters:

  • object: This Parameter is required to specify the object to convert to an array.
  • mapFunction: This Parameter specifies the map function to call on each item of the array.
    • element: It specifies the current element.
    • currentIndex: This Parameter specifies the array index of the current element.
  • thisValue: This Parameter specifies the value to use as this when executing the mapFunction.

Return Value:

It returns an array object or instance of an arrray. 

Example 1: In this example, we will be using Array from() method to create an array from the string value.

JavaScript
// Creating array from input string
let myArr = Array.from(
    "GeeksForGeeks");

// Display output
console.log(myArr);

Output
[
  'G', 'e', 'e', 'k',
  's', 'F', 'o', 'r',
  'G', 'e', 'e', 'k',
  's'
]

Example 2: In this example, we will be using Array from() method to create an array from the string value.

JavaScript
// Creating array form the given string
let myArr = Array.from("45878965412365");

// Display output
console.log(myArr);

Output
[
  '4', '5', '8', '7',
  '8', '9', '6', '5',
  '4', '1', '2', '3',
  '6', '5'
]

 We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article.

Supported Browsers:

  • Chrome 51
  • Edge 15
  • Firefox 54
  • Safari 10
  • Opera 38

Next Article

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy