JavaScript ã®ä¾å¤ "a declaration in the head of a for-of loop can't have an initializer" ã¯ã for...of ã«ã¼ãã®å
é ã« |for (var i = 0 of iterable)
| ã®ããã«åæååãå«ã¾ãã¦ããå ´åã«çºçãã¾ãããã㯠for-of ã«ã¼ãã§ã¯è¨±å¯ããã¦ãã¾ããã
SyntaxError: for-of loop head declarations cannot have an initializer (Edge)
SyntaxError: a declaration in the head of a for-of loop can't have an initializer (Firefox)
SyntaxError: for-of loop variable declaration may not have an initializer. (Chrome)
ã¨ã©ã¼ã¿ã¤ã ä½ããã¾ããããªãã£ãã®ãï¼
for...of ã«ã¼ãã®å
é ã«åæåå¼ãå«ã¾ãã¦ãã¾ããã¤ã¾ãã |for (var i = 0 of iterable)
| ã®ããã«å¤æ°ã宣è¨ãããå¤ã代å
¥ããã¦ãã¾ããããã¯ã for-of ã«ã¼ãã§ã¯è¨±å¯ããã¦ãã¾ãããåæåã§ãã for
ã«ã¼ãã使ç¨ããæ¹ãè¯ãããããã¾ããã
for-of
ã«ã¼ã
let iterable = [10, 20, 30];
for (let value = 50 of iterable) {
console.log(value);
}
// SyntaxError: a declaration in the head of a for-of loop can't
// have an initializer
æå¹ãª for-of
ã«ã¼ã
for-of
ã«ã¼ãã®ãããã¼ããåæåå (value = 50
) ãåãé¤ãå¿
è¦ãããã¾ããããããã50 ããªãã»ããå¤ã«ãããã¨ãã¦ããã®ã§ãããããããã¨ãã°ã«ã¼ãã®ããã£ã¼å
ã§ 50 ãå ãããã¾ãã
let iterable = [10, 20, 30];
for (let value of iterable) {
value += 50;
console.log(value);
}
// 60
// 70
// 80
é¢é£é
ç®
for...of
for...in
â strict ã¢ã¼ãã§ã¯åæ§ã«åæåã§ããªã (SyntaxError: for-in loop head declarations may not have initializers)for
â å復æã«åæååã許å¯ãã¦ããRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4