| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
SyntaxError: for-in loop head declarations cannot have an initializer (Edge)
SyntaxError: for-in loop head declarations may not have initializers (Firefox)
SyntaxError: for-in loop variable declaration may not have an initializer. (Chrome)
(Strict) SyntaxError.
for...in . , |for (var i = 0 in obj)| . (non-strict) |for (var i in obj)| . SyntaxError .
SyntaxError .
const obj = { a: 1, b: 2, c: 3 };
for (const i = 0 in obj) {
console.log(obj[i]);
}
// SyntaxError: for-in loop head declarations may not have initializers
for-in (i = 0) .
"use strict";
var obj = { a: 1, b: 2, c: 3 };
for (var i in obj) {
console.log(obj[i]);
}
for...in . (Array) for-in for ? for :
var arr = ["a", "b", "c"];
for (var i = 2; i < arr.length; i++) {
console.log(arr[i]);
}
// "c"
This page was last modified on 2024 12 17 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |