javascript pseudo-arrays vs standard arrays

pseudo-array

1. is an object

2. There must be a length attribute, and the length value is of type number

3. If the length of this object is not 0, then there must be data stored according to the subscript

standard array

Determine whether the data is a standard array:

Object.prototype.toString.call(data) === '[Object Array]'

How to Convert Pseudo Arrays to Standard Arrays

1. Array.prototype.slice.call(arguments):

Can convert an object with a length property to an array.

2. Two uses of slice:

a: string.slice: return string

b: array.slice: return array

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325838377&siteId=291194637