Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 801b5e3

Browse files
Examples for for..of and spread
1 parent 4b116d9 commit 801b5e3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

‎JavaScript/d-for-of.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
function* ids(...args) {
4+
let i = 0;
5+
while (args.length > i) {
6+
const id = args[i++];
7+
if (id === undefined) return -1;
8+
yield id;
9+
}
10+
}
11+
12+
const id = ids(1011, 1078, 1292, 1731, undefined, 1501, 1550);
13+
for (const val of id) {
14+
console.log({ val });
15+
}

‎JavaScript/e-spread.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
function* ids(...args) {
4+
let i = 0;
5+
while (args.length > i) {
6+
const id = args[i++];
7+
if (id === undefined) return -1;
8+
yield id;
9+
}
10+
}
11+
12+
const id = ids(1011, 1078, 1292, 1731, undefined, 1501, 1550);
13+
console.log([...id]);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /