@@ -287,7 +287,7 @@ <h1>JavaScript Garden</h1>
287
287
< article > < section > < header > < h2 id ="functions "> Functions < a href ="#intro "> #top</ a > </ h2 > </ header >
288
288
< p > Functions in JavaScript are first class objects, which means that they can be
289
289
passed around like any other value. One common use of this feature is to pass
290
- an < em > anonymous function</ em > as a callback to another, possible asynchronous function.</ p >
290
+ an < em > anonymous function</ em > as a callback to another, possibly asynchronous function.</ p >
291
291
</ section > < section > < header > < h3 > The < code > function</ code > declaration</ h3 > </ header >
292
292
< pre > < code > function foo() {}
293
293
</ code > </ pre >
@@ -563,15 +563,15 @@ <h1>JavaScript Garden</h1>
563
563
}
564
564
foo(1, 2, 3);
565
565
</ code > </ pre >
566
- < aside >
567
- < p > < strong > ES5 Note:</ strong > These getters and setters are not created in strict mode.</ p >
568
- </ aside >
569
566
</ section > < section > < header > < h3 > Performance myths and truths</ h3 > </ header >
570
567
< p > The < code > arguments</ code > is, except for the two cases named at the start of this section,
571
568
always created. It doesn't matter whether it is used or not. Both getters and
572
569
setters are < strong > always</ strong > created; thus, using it has nearly no performance impact
573
570
at all, especially not in real world code where there is more than an access to
574
571
the arguments object properties.</ p >
572
+ < aside >
573
+ < p > < strong > ES5 Note:</ strong > These getters and setters are not created in strict mode.</ p >
574
+ </ aside >
575
575
< p > However, there is one case which will drastically reduce the performance in
576
576
modern JavaScript engines. That case is the use of < code > arguments.callee</ code > .</ p >
577
577
< pre > < code > function foo() {
@@ -962,11 +962,11 @@ <h1>JavaScript Garden</h1>
962
962
</ code > </ pre >
963
963
< p > Since it is not possible to change the behavior of the < code > for in</ code > loop itself, it
964
964
is necessary to filter out the unwanted properties inside the loop body itself,
965
- this is done by using the < a href ="#hasownproperty "> < code > hasOwnProperty</ code > </ a > method of the
966
- object . </ p >
965
+ this is done by using the < a href ="#hasownproperty "> < code > hasOwnProperty</ code > </ a > method of
966
+ objects . </ p >
967
967
< aside >
968
968
< p > < strong > Note:</ strong > Since the < code > for in</ code > always traverses the complete prototype chain, it
969
- will get slow with each additional layer of inheritance added to an object.</ p >
969
+ will get slower with each additional layer of inheritance added to an object.</ p >
970
970
</ aside >
971
971
</ section > < section > < header > < h3 > Using < code > hasOwnProperty</ code > for filtering</ h3 > </ header >
972
972
< pre > < code > // still the foo from above
@@ -978,8 +978,8 @@ <h1>JavaScript Garden</h1>
978
978
</ code > </ pre >
979
979
< p > This version is the only correct one to use. Due to the use of < code > hasOwnPropery</ code > it
980
980
will < strong > only</ strong > print out < code > moo</ code > . When < code > hasOwnProperty</ code > is left out, the code is
981
- prone to errors when the native prototypes have been extended; for example,
982
- < code > Object.prototype</ code > .</ p >
981
+ prone to errors when the native prototypes ( for example,
982
+ < code > Object.prototype</ code > ) have been extended .</ p >
983
983
< p > One widely used framework which does this is < a href ="http://www.prototypejs.org/ "> Prototype</ a > . When this
984
984
framework is included, < code > for in</ code > loops that do not use < code > hasOwnProperty</ code > are
985
985
guaranteed to break.</ p >
@@ -1104,7 +1104,7 @@ <h1>JavaScript Garden</h1>
1104
1104
1105
1105
// These are false
1106
1106
10 == 010;
1107
- 10 == '-10'
1107
+ 10 == '-10';
1108
1108
</ code > </ pre >
1109
1109
< aside >
1110
1110
< p > < strong > Note:</ strong > Number literals that start with a < code > 0</ code > are interpreted as octal (Base
0 commit comments