@@ -332,21 +332,21 @@ <h1>JavaScript Garden</h1>
332
332
< pre > < code > this;
333
333
</ code > </ pre >
334
334
< p > When using < code > this</ code > in global scope, it will simply refer to the < em > global</ em > object.</ p >
335
- </ section > < section > < header > < h3 > Calling a Function </ h3 > </ header >
335
+ </ section > < section > < header > < h3 > Calling a function </ h3 > </ header >
336
336
< pre > < code > foo();
337
337
</ code > </ pre >
338
338
< p > Here < code > this</ code > will again refer to the < em > global</ em > object.</ p >
339
- </ section > < section > < header > < h3 > Calling a Method </ h3 > </ header >
339
+ </ section > < section > < header > < h3 > Calling a method </ h3 > </ header >
340
340
< pre > < code > test.foo();
341
341
</ code > </ pre >
342
342
< p > In this example < code > this</ code > will refer to < code > test</ code > .</ p >
343
- </ section > < section > < header > < h3 > Calling a Constructor </ h3 > </ header >
343
+ </ section > < section > < header > < h3 > Calling a constructor </ h3 > </ header >
344
344
< pre > < code > new foo();
345
345
</ code > </ pre >
346
346
< p > A function call that is preceded by the < code > new</ code > keyword acts as
347
347
a < a href ="#constructors "> constructor</ a > . Inside the function < code > this</ code > will refer to a newly
348
348
created < code > Object</ code > .</ p >
349
- </ section > < section > < header > < h3 > Explicit setting</ h3 > </ header >
349
+ </ section > < section > < header > < h3 > Explicit setting of < code > this </ code > </ h3 > </ header >
350
350
< pre > < code > function foo(a, b, c) {}
351
351
352
352
var bar = {};
@@ -386,7 +386,7 @@ <h1>JavaScript Garden</h1>
386
386
}
387
387
</ code > </ pre >
388
388
< p > < code > that</ code > is just a normal name, but it is commonly used for the reference to an
389
- outer < code > this</ code > . In combination with < a href ="#closures "> Closures </ a > , it can also be used to
389
+ outer < code > this</ code > . In combination with < a href ="#closures "> closures </ a > , it can also be used to
390
390
pass < code > this</ code > values around.</ p >
391
391
</ section > < section > < header > < h3 > Assigning methods</ h3 > </ header >
392
392
< p > Another thing that does < strong > not</ strong > work in JavaScript is < strong > assigning</ strong > a method
@@ -523,7 +523,7 @@ <h1>JavaScript Garden</h1>
523
523
will override the default < code > arguments</ code > object.</ p >
524
524
</ aside > </ section > </ article >
525
525
526
- < article > < section > < header > < h2 id ="scopes "> Scopes and Namespaces < a href ="#intro "> ^</ a > </ h2 > </ header >
526
+ < article > < section > < header > < h2 id ="scopes "> Scopes and namespaces < a href ="#intro "> ^</ a > </ h2 > </ header >
527
527
< p > Although JavaScript deals fine with the block scope syntax of two matching curly
528
528
braces, it does < strong > not</ strong > support block scope; thus, all that is left is the
529
529
< em > function scope</ em > .</ p >
@@ -538,7 +538,7 @@ <h1>JavaScript Garden</h1>
538
538
< p > Each time a variable is referenced, JavaScript will traverse upwards through all
539
539
the scopes until it finds it. In the case that it reaches the global scope and
540
540
still has not found the requested name, it will raise a < code > ReferenceError</ code > .</ p >
541
- </ section > < section > < header > < h3 > The Bane of global Variables </ h3 > </ header >
541
+ </ section > < section > < header > < h3 > The bane of global variables </ h3 > </ header >
542
542
< pre > < code > // script A
543
543
foo = '42';
544
544
@@ -637,8 +637,8 @@ <h1>JavaScript Garden</h1>
637
637
) // and return the function object
638
638
() // call the result of the evaluation
639
639
</ code > </ pre >
640
- < p > There are other ways for evaluating and calling the function expression which -
641
- while different in syntax - do the exact same thing.</ p >
640
+ < p > There are other ways for evaluating and calling the function expression; which
641
+ while different in syntax, do the exact same thing.</ p >
642
642
< pre > < code > // Two other ways
643
643
+function(){}();
644
644
(function(){}());
@@ -901,8 +901,8 @@ <h1>JavaScript Garden</h1>
901
901
will < strong > only</ strong > print out < code > moo</ code > . When < code > hasOwnProperty</ code > is left out, the code is
902
902
prone to errors when the native prototypes have been extended; for example,
903
903
< code > Object.prototype</ code > .</ p >
904
- < p > One widely used framework which does this is < a href ="http://www.prototypejs.org/ "> < strong > Prototype</ strong > </ a > . When this
905
- framework is included, < code > for in</ code > loops that doe not use < code > hasOwnProperty</ code > are
904
+ < p > One widely used framework which does this is < a href ="http://www.prototypejs.org/ "> Prototype</ a > . When this
905
+ framework is included, < code > for in</ code > loops that do not use < code > hasOwnProperty</ code > are
906
906
guaranteed to break.</ p >
907
907
</ section > < section > < header > < h3 > Best practices</ h3 > </ header >
908
908
< p > It is recommended to < strong > always</ strong > use < code > hasOwnProperty</ code > . Never should any
@@ -947,10 +947,10 @@ <h1>JavaScript Garden</h1>
947
947
following strings. < code > Arguments</ code > , < code > Array</ code > , < code > Boolean</ code > , < code > Date</ code > , < code > Error</ code > ,
948
948
< code > Function</ code > , < code > JSON</ code > , < code > Math</ code > , < code > Number</ code > , < code > Object</ code > , < code > RegExp</ code > , < code > String</ code > .</ p >
949
949
</ aside >
950
- < p > In order to retrieve the value of < em > Class</ em > one can has to make use of the
950
+ < p > In order to retrieve the value of < code > [[ Class]] </ code > one can has to make use of the
951
951
< code > toString</ code > method of < code > Object</ code > .</ p >
952
952
</ section > < section > < header > < h3 > The Class of an object</ h3 > </ header >
953
- < p > The specification gives exactly one way of accessing the < em > Class</ em > value.</ p >
953
+ < p > The specification gives exactly one way of accessing the < code > [[ Class]] </ code > value.</ p >
954
954
< pre > < code > function is(type, obj) {
955
955
var cls = Object.prototype.toString.call(obj).slice(8, -1);
956
956
return cls === type;
@@ -959,8 +959,8 @@ <h1>JavaScript Garden</h1>
959
959
is('String', 'test'); // true
960
960
is('String', new String('test')); // true
961
961
</ code > </ pre >
962
- < p > < code > Object.prototype.toString</ code > gets called with < a href ="#this "> this</ a >
963
- being set to the object which its < em > Class</ em > value should be retrieved.</ p >
962
+ < p > < code > Object.prototype.toString</ code > gets called with the value of < a href ="#this "> this</ a > being set
963
+ to the object whose < code > [[ Class]] </ code > value should be retrieved.</ p >
964
964
</ section > < section > < header > < h3 > Testing for undefined variables</ h3 > </ header >
965
965
< pre > < code > typeof foo !== 'undefined'
966
966
</ code > </ pre >
0 commit comments