Skip to content

Commit 498e3d7

Browse files
author
Zirak
committed
added missing semi-colons and fixed syntax error
1 parent e99c3fe commit 498e3d7

File tree

3 files changed

+49
-49
lines changed

3 files changed

+49
-49
lines changed

basic.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ var obj = {
2323
// dot notation
2424
obj.sum = function() {
2525
return this.a + this.b;
26-
}
26+
};
2727

2828
// bracket/array notation
2929
obj['product'] = function() {
3030
return this['a'] + this['b'];
31-
}
31+
};
3232

3333
/*
3434
Inheritance is sweet!
3535
Objects inherit from other objects
3636
*/
3737
var point = {
38-
translate: function(x, y) {
39-
this.x += x;
40-
this.y += y;
41-
},
42-
moveTo: function(x, y) {
43-
this.x = x;
44-
this.y = y;
45-
}
46-
};
38+
translate: function(x, y) {
39+
this.x += x;
40+
this.y += y;
41+
},
42+
moveTo: function(x, y) {
43+
this.x = x;
44+
this.y = y;
45+
}
46+
};
4747

4848
// Create a new object with point as the prototype
4949
var inheritingPoint = Object.create(point);
@@ -64,7 +64,7 @@ var inheritingPoint = Object.create(point);
6464
// moveTo is called with a context of "inheritingPoint"
6565
// which means that within "moveTo", this === inheritingPoint
6666
// so "x" is set on inheritingPoint, not point
67-
inheritingPoint.moveTo(100, 75);
67+
inheritingPoint.moveTo(100, 75);
6868
inheritingPoint.hasOwnProperty(x); // true
6969

7070
/*
@@ -77,12 +77,12 @@ var point3d = Object.create(point);
7777
point3d.translate = function(x, y, z) {
7878
point.translate.call(this, x, y); // Avoid code duplication - use the "parent" function
7979
this.z += z;
80-
}
80+
};
8181

8282
point3d.moveTo = function(x, y, z) {
8383
point.moveto.call(this, x, y);
8484
this.z = z;
85-
}
85+
};
8686

8787
var new3DPoint = Object.create(point3d);
88-
newPoint.moveTo(42, 37, 96);
88+
newPoint.moveTo(42, 37, 96);

constructor.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
*/
66

77
// Construcors are just functions
8-
var Point = function(x, y)
8+
var Point = function(x, y) {
99
this.x = x;
1010
this.y = y;
11-
}
11+
};
1212

1313
// Put "methods" on the prototype property of the function
1414
Point.prototype.translate = function(x, y) {
1515
this.x += x;
1616
this.y += y;
17-
}
18-
17+
};
18+
1919
// Use the "new" keyword to create a new object
2020
// with a prototype equal to Point.prototype
2121
var point = new Point(17, 42);
@@ -27,16 +27,16 @@ point.translate(5, 6);
2727
var Point3d = function(x, y, z) {
2828
Point.call(this, x, y);
2929
this.z = z;
30-
}
31-
30+
};
31+
3232
Point3d.prototype = new Point();
3333
// OR
3434
Point3d.prototype = Object.create(Point.prototype); // probably better
35-
35+
3636
Point3d.prototype.translate = function(x, y, z) {
3737
Point.prototype.translate.call(this, x, y);
3838
this.z += z;
39-
}
40-
39+
};
40+
4141
var point3d = new Point3d(19, 20, 21);
42-
point3d.translate(4, 5, 6);
42+
point3d.translate(4, 5, 6);

initializer.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
Initializer functions keep all the logic within the function itself
99
*/
1010
var point = {
11-
init: function(x, y) {
12-
this.x = x;
13-
this.y = y;
14-
},
15-
translate: function(x, y) {
16-
this.x += x;
17-
this.y += y;
18-
}
19-
};
11+
init: function(x, y) {
12+
this.x = x;
13+
this.y = y;
14+
},
15+
translate: function(x, y) {
16+
this.x += x;
17+
this.y += y;
18+
}
19+
};
2020

2121
var obj = Object.create(point);
2222
obj.init(7, 9);
@@ -31,12 +31,12 @@ var point3d = Object.create(point);
3131
point3d.init = function(x, y, z) {
3232
point.init.call(this, x, y);
3333
this.z = z;
34-
}
34+
};
3535

3636
point3d.translate = function(x, y, z) {
3737
point.translate.call(this, x, y);
3838
this.z += z;
39-
}
39+
};
4040

4141
var obj = Object.create(point3d);
4242
obj.init(42, 17, 29);
@@ -46,28 +46,28 @@ obj.translate(7, 9, 12);
4646
Defaults are awesome and DRY
4747
*/
4848
var point = {
49-
init: function(x, y) {
50-
this.x = (typeof x === 'undefined' || x === null) ? 0 : x;
51-
this.y = (typeof y === 'undefined' || y === null) ? 0 : y;
52-
},
53-
translate: function(x, y) {
54-
this.x += x;
55-
this.y += y;
56-
}
57-
};
49+
init: function(x, y) {
50+
this.x = (typeof x === 'undefined' || x === null) ? 0 : x;
51+
this.y = (typeof y === 'undefined' || y === null) ? 0 : y;
52+
},
53+
translate: function(x, y) {
54+
this.x += x;
55+
this.y += y;
56+
}
57+
};
5858

5959
var point3d = Object.create(point);
60-
60+
6161
point3d.init = function(x, y, z) {
6262
point.init.call(this, x, y);
6363
this.z = (typeof z === 'undefined' || z === null) ? 0 : z;
64-
}
64+
};
6565

6666
point3d.translate = function(x, y, z) {
6767
point.translate.call(this, x, y);
6868
this.z += z;
69-
}
69+
};
7070

7171
var obj = Object.create(point3d);
7272
obj.init(42, 17, 29);
73-
obj.translate(7, 9, 12);
73+
obj.translate(7, 9, 12);

0 commit comments

Comments
 (0)