The concrete usage of Array Operation method in JS
This article mainly explains "the specific usage of Array operation method in JS". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the specific usage of Array operation method in JS.
1. Array.from () creates a new array instance from a similar array or iterable object.
Console.log (Array.from ("foo")); / / expected output: Array ["f", "o", "o"] console.log (Array.from ([1,2,3], (x) = > x + x)); / / expected output: Array [2,4,6]
2. Array.isArray () is used to determine whether the value passed is an Array.
Array.isArray ([1,2,3]); / / trueArray.isArray ({foo: 123}); / / falseArray.isArray ("foobar"); / / falseArray.isArray (undefined); / / false
3. Array.of () creates a new array instance with variable number parameters.
Regardless of the number or type of parameters.
Array.of (7); / / [7] Array.of (1,2,3); / / [1,2,3] Array (7); / / [,] Array (1,2,3); / / [1,2,3] / / es5if (! Array.of) {Array.of = function () {return Array.prototype.slice.call (arguments);} } at this point, I believe you have a deeper understanding of "the specific use of Array operation methods in JS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!