ECMA Script6 Array.from method

Below is a simple example of the usage of the Array.from method which will create a new array instance with the word “hello” in front of every element of the old array.

let greeting = ["world", "man", "you"];

let hello = {hi : "hello"}

let arry = Array.from(greeting, function(value) {
	return this.hi + " " + value;
}, hello);

The result is [ “hello world”, “hello man”, “hello you” ]

The full function is as follow:-

Array.from(iterable, mapFunc, this);

Like this post? Kindly share!