Arrays-Static Methods

Table of contents

No heading

No headings in the article.

  • Array.from(): Array.from() returns an array from any iterable object.We can only use it as Array.from() we if use something like below example array will return undefined. So in the below example we have declared a string to a let variable and using Array.from() method we can be able to return an array.

image.png

  • Array.isArray(). It is also one of the static methods helps in finding the given object is Array or not. Array.isArray() returns true if an object is an "Array". Otherwise false. Please see two below examples for clear understanding.

image.png image.png

  • Array.of()

The Array.of() method creates a new Array instance from a variable number of arguments, regardless of number or type of the arguments.

image.png

image.png