Skip to content

Commit 4e82088

Browse files
committed
for in loop
length' is a non-enumerable property of an array.
1 parent 781a8f4 commit 4e82088

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

doc/en/object/forinloop.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ When `hasOwnProperty` is left out, the code is prone to errors in cases where
4747
the native prototypes - e.g. `Object.prototype` -
4848
have been extended.
4949

50+
> Tried in jeforth
51+
> js> [].length . \ ==> 0 OK.
52+
> js> [] obj>keys . \ ==> "" OK.
53+
> js> [].hasOwnProperty("length") \ ==> true (boolean).
54+
> So 'length' is a non-enumerable property of an array.
55+
5056
In newer versions of ECMAScript, non-enumerable properties can be defined with
5157
`Object.defineProperty`, reducing the risk of iterating over properties without
5258
using `hasOwnProperty`. Nonetheless, care must be taken when using older
5359
libraries like [Prototype][1], which does not yet take advantage of new ECMAScript features.
5460
When this framework is included, `for in` loops that do not use
5561
`hasOwnProperty` are guaranteed to break.
5662

57-
> Tried in jeforth
58-
> js> [].length . \ ==> 0 OK
59-
> js> [] obj>keys . \ ==> "" OK
60-
> js> [].hasOwnProperty("length") \ ==> true (boolean)
61-
> So 'length' is a non-enumerable property of an array.
62-
6363
### In Conclusion
6464

6565
It is recommended to **always** use `hasOwnProperty` in ECMAScript 3 or lower, as well as

0 commit comments

Comments
 (0)