Home > Common Problem > What are the built-in iterable objects in js?

What are the built-in iterable objects in js?

尊渡假赌尊渡假赌尊渡假赌
Release: 2023-11-21 16:49:39
Original
1496 people have browsed it

The built-in iterable objects in JavaScript include "Array", "Map", "Set", "String", "TypedArray", "NodeList" and "Arguments": 1. Array, array object; 2 , Map, is a collection of key-value pairs; 3. Set, is a collection; 4. String, a string object; 5. TypedArray, an array-like object; 6. NodeList, a node list object, etc.

What are the built-in iterable objects in js?

# Operating system for this tutorial: Windows 10 system, Dell G3 computer.

In JavaScript, some built-in objects are iterable, which means they support traversal using for...of loops. Here are some of the built-in iterable objects in JavaScript:

  1. Array: Array objects are one of the most commonly used iterable objects and can be used to iterate over the elements in the array using a for…of loop.

  2. Map: Map object is a collection of key-value pairs, and you can use the for...of loop to traverse the key-value pairs.

  3. Set: A Set object is a collection whose elements can be traversed using a for…of loop.

  4. String: The string object is also an iterable object, and you can use the for...of loop to traverse the characters in it.

  5. TypedArray: A TypedArray object is an array-like object whose elements can be iterated over using a for…of loop.

  6. NodeList: The NodeList object is a node list object, and you can use the for...of loop to traverse the nodes in it.

  7. Arguments object: The Arguments object is an array-like object of function parameters, and you can use the for...of loop to traverse the parameters in it.

In addition to these built-in iterable objects, developers can also customize iterable objects. They only need to implement the Symbol.iterator method on the object to make the object an iterable object. .

The above is the detailed content of What are the built-in iterable objects in js?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template