File tree Expand file tree Collapse file tree 7 files changed +10
-10
lines changed Expand file tree Collapse file tree 7 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 1
1
## Array Iteration and Properties
2
2
3
3
Although arrays in JavaScript are objects, there are no good reasons to use
4
- the [ ` for in loop ` ] ( #object.forinloop ) in for iteration on them . In fact, there
4
+ the [ ` for in ` ] ( #object.forinloop ) loop . In fact, there
5
5
are a number of good reasons ** against** the use of ` for in ` on arrays.
6
6
7
7
> ** Note:** JavaScript arrays are ** not** * associative arrays* . JavaScript only
Original file line number Diff line number Diff line change @@ -51,10 +51,10 @@ In the example above `obj.x` and `obj.y` can be deleted because they have no
51
51
GLOBAL_OBJECT.a; // undefined
52
52
53
53
Here we use a trick to delete ` a ` . [ ` this ` ] ( #function.this ) here refers
54
- to the Global object and we explicitly declare variable ` a ` as it's property
54
+ to the Global object and we explicitly declare variable ` a ` as its property
55
55
which allows us to delete it.
56
56
57
- IE (at least 6-8) has some bugs, so code above doesn't work.
57
+ IE (at least 6-8) has some bugs, so the code above doesn't work.
58
58
59
59
### Function arguments and built-ins
60
60
Original file line number Diff line number Diff line change 2
2
3
3
Functions in JavaScript are first class objects. That means they can be
4
4
passed around like any other value. One common use of this feature is to pass
5
- an * anonymous function* as a callback to another, possibly asynchronous function.
5
+ an * anonymous function* as a callback to another, possibly an asynchronous function.
6
6
7
7
### The ` function ` Declaration
8
8
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ has been applied.
153
153
Without the knowledge about * hoisting* , the below code might seem to raise a
154
154
` ReferenceError ` .
155
155
156
- // check whether SomeImportantThing has been initiliazed
156
+ // check whether SomeImportantThing has been initialized
157
157
if (!SomeImportantThing) {
158
158
var SomeImportantThing = {};
159
159
}
@@ -163,7 +163,7 @@ moved to the top of the *global scope*.
163
163
164
164
var SomeImportantThing;
165
165
166
- // other code might initiliaze SomeImportantThing here, or not
166
+ // other code might initialize SomeImportantThing here, or not
167
167
168
168
// make sure it's there
169
169
if (!SomeImportantThing) {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ literals act as objects too.
28
28
Objects in JavaScript can also be used as a [ * Hashmap* ] [ 1 ] ; they mainly consist
29
29
of named properties mapping to values.
30
30
31
- Using a object literal - ` {} ` notation - it is possible to create a
31
+ Using an object literal - ` {} ` notation - it is possible to create a
32
32
plain object. This new object [ inherits] ( #object.prototype ) from ` Object.prototype ` and
33
33
has no [ own properties] ( #object.hasownproperty ) defined on it.
34
34
@@ -42,7 +42,7 @@ has no [own properties](#object.hasownproperty) defined on it.
42
42
The properties of an object can be accessed in two ways, via either the dot
43
43
notation or the square bracket notation.
44
44
45
- var foo = {name: 'Kitten '}
45
+ var foo = {name: 'kitten '}
46
46
foo.name; // kitten
47
47
foo[ 'name'] ; // kitten
48
48
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ necessary to use an *external* `hasOwnProperty` in order to get correct results.
44
44
// Use another Object's hasOwnProperty and call it with 'this' set to foo
45
45
({}).hasOwnProperty.call(foo, 'bar'); // true
46
46
47
- // It's also possible use the hasOwnProperty property from the Object property for this purpuse
47
+ // It's also possible use the hasOwnProperty property from the Object property for this purpose
48
48
Object.prototype.hasOwnProperty.call(obj, 'bar'); // true
49
49
50
50
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ function that will get called by either of the timeout functions.
138
138
function foo(a, b, c) {}
139
139
140
140
// NEVER use this
141
- setTimeout('foo(1,2, 3)', 1000)
141
+ setTimeout('foo(1, 2, 3)', 1000)
142
142
143
143
// Instead use an anonymous function
144
144
setTimeout(function() {
You can’t perform that action at this time.
0 commit comments