--- title: for each...in slug: Web/JavaScript/Reference/Statements/for_each...in tags: - Deprecated - E4X - JavaScript - Obsolete - Statement translation_of: Archive/Web/JavaScript/for_each...in ---
The for each...in statement is deprecated as the part of ECMA-357 (E4X) standard. E4X support has been removed. Consider using for...of instead.
Firefox now warns about the usage of for each...in and it no longer works starting with Firefox 57.
Please see Warning: JavaScript 1.6's for-each-in loops are deprecated for migration help.
for each...in 문은 객체의 모든 속성 값에 대해 지정된 변수를 반복합니다. 각각의 고유한 특성에 대해 지정된 명령문이 실행됩니다.
for each (variable in object) {
statement
}
variableobjectstatement일부 기본 제공 속성은 반복되지 않습니다. 여기에는 객체 기본 제공 메서드 전부가 포함됩니다.
ex) String의 indexOf 메소드.
그러나 사용자가 정의한 모든 속성은 반복됩니다.
for each...inWarning: Never use a loop like this on arrays. Only use it on objects. See for...in for more details.
The following snippet iterates over an object's properties, calculating their sum:
var sum = 0;
var obj = {prop1: 5, prop2: 13, prop3: 8};
for each (var item in obj) {
sum += item;
}
console.log(sum); // logs "26", which is 5+13+8
Not part of a current ECMA-262 specification. Implemented in JavaScript 1.6 and deprecated.
{{Compat("javascript.statements.for_each_in")}}