Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-study-front-share
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
yifu-study
front
yifu-study-front-share
Commits
15c0586e
Commit
15c0586e
authored
Apr 26, 2022
by
张芳利
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Map 和 Object.md
parent
f4a065ec
Pipeline
#15687
canceled with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
Map 和 Object.md
source/_posts/Map 和 Object.md
+1
-1
No files found.
source/_posts/Map 和 Object.md
View file @
15c0586e
...
...
@@ -266,7 +266,7 @@ Objects 和 Maps 类似的是,它们都允许你按键存取一个值、删除
|
**next**
| 一个无参数或者一个参数的函数,返回一个应当拥有以下两个属性的对象:
<br
/>
**done(boolean)**
<br
/>
如果迭代器可以产生序列中的下一个值,则为 false。
<br
/>
如果迭代器已将序列迭代完毕,则为 true。
<br
/>
这种情况下,value 是可选的,如果它依然存在,即为迭代结束之后的默认返回值。
<br
/>
**next()**
方法必须返回一个对象,
<br
/>
该对象应当有两个属性: done 和 value,如果返回了一个非对象值(比如 false 或 undefined),
<br
/>
则会抛出一个
[
TypeError
](
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypeError
)
异常("iterator.next() returned a non-object value")。 |
Iterator 迭代器是一种接口,为不同的数据结构提供统一的访问机制,这个访问机制主要是遍历,我们知道,在数组、在对象、在类数组、在map、在set里面,都可以用for of或者扩展运算符来得到一个数组或者是遍历当前的数据结构,为什么能够遍历的原因就是因为存在这个Iterator 迭代器这个东西,所以我们可以用for of来提供一个统一的遍历,因此这个底层或者是Itrator它最初是为了for of而设计的。
Iterator 迭代器是一种接口,为不同的数据结构提供统一的访问机制,这个访问机制主要是遍历,我们知道,在数组、在对象、在类数组、在map、在set里面,都可以用for of或者扩展运算符来得到一个数组或者是遍历当前的数据结构,为什么能够遍历的原因就是因为存在这个Iterator 迭代器这个东西,所以我们可以用for of来提供一个统一的遍历,因此这个底层或者是Itrator它最初是为了for of而设计的。
为了给所有的
[
数据结构
](
https://so.csdn.net/so/search?q=%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84&spm=1001.2101.3001.7020
)
有一个统一的遍历接口,统一的访问机制,因此就产生了迭代器。
<br
/>
迭代器的特点:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment