8000 Improve examples readability · HowProgrammingWorks/Prototype@5226aae · GitHub
[go: up one dir, main page]

Skip to content

Commit 5226aae

Browse files
committed
Improve examples readability
1 parent 8d23dc2 commit 5226aae

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

JavaScript/3-class.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,9 @@ class Point {
2121
}
2222
}
2323

24-
console.log(
25-
'Point prototype:',
26-
Point.prototype
27-
);
28-
console.log(
29-
'move prototype:',
30-
Point.prototype.move.prototype
31-
);
32-
console.log(
33-
'constructor prototype:',
34-
Point.constructor.prototype
35-
);
36-
console.log(
37-
'prototype constructor prototype:',
38-
Point.prototype.constructor.prototype
39-
);
24+
console.log('Point prototype:', Point.prototype);
25+
console.log('move prototype:', Point.prototype.move.prototype);
26+
console.log('constructor prototype:', Point.constructor.prototype);
4027

4128
const p1 = new Point(10, 20);
4229
p1.move(-5, 10);

JavaScript/6-logger.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ logger.colors = {
1414
info: '\x1b[1;37m',
1515
};
1616

17+
// Usage
18+
1719
const warning = logger('warning');
1820
const error = logger('error');
1921
const debug = logger('debug');

JavaScript/7-prototype.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Logger.prototype.log = function(s) {
1515
console.log(this.color + date + '\t' + s);
1616
};
1717

18+
// Usage
19+
1820
const warning = new Logger('warning');
1921
const error = new Logger('error');
2022
const debug = new Logger('debug');

JavaScript/8-class.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Logger.colors = {
1717
info: '\x1b[1;37m',
1818
};
1919

20+
// Usage
21+
2022
const warning = new Logger('warning');
2123
const error = new Logger('error');
2224
const debug = new Logger('debug');

JavaScript/9-inherits.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Square(x, y, side) {
1818
Object.setPrototypeOf(Square.prototype, Rect.prototype);
1919

< 56CF /code>
2020
// const util = require('util');
21-
// util.inherits(Square, Rect);
21+
// util.inherits(Square, Rect); // for Node.js
2222

2323
// Square.prototype = Object.create(Rect.prototype);
2424
// Square.prototype.constructor = Square;

0 commit comments

Comments
 (0)
0