[04] Web front-end advanced - JS pseudo-array



1. Characteristics of pseudo-arrays

  1. Has the lenght attribute
  2. Data can be accessed using subscripts
  3. Methods that do not have an array, such as push( ), pop( ), etc.

2. Pseudo array

It is essentially an object with attributes such as index and length, but cannot use methods of arrays, such as foreach( ), filter( ), map( ), find( ), reduce(), etc., but can traverse the array access (for loop)

Common Pseudo-Arrays

  1. strings and such
  2. function arguments (parameters),
  3. The collection of elements obtained by document.getElementByTagName( ), etc.
  4. An object whose key is 0, 1, 2 numbers and has length ambiguity
 //1.字符串
    let str = 'hello'

Guess you like

Origin blog.csdn.net/qq_33966310/article/details/126673008