Skip to content

Commit c4df703

Browse files
committed
Change examples
1 parent b831864 commit c4df703

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

JavaScript/6-spread.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
'use strict';
22

3-
const f1 = (...args) => console.log(args);
3+
const f1 = (...args) => {
4+
console.log(args);
5+
};
46

57
f1(1, 2, 3);
68

79
const f2 = (...args) => {
810
args.forEach(arg => {
11+
console.log('Type: ' + typeof(arg));
912
if (typeof(arg) === 'object') {
10-
console.log(typeof(arg) + ': ' + JSON.stringify(arg));
13+
console.log('Value: ' + JSON.stringify(arg));
1114
} else {
12-
console.log(typeof(arg) + ': ' + arg);
15+
console.log('Value: ' + arg);
1316
}
1417
});
1518
};

JavaScript/8-method.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const obj1 = {
4-
f1: function inc(a) {
4+
fn1: function inc(a) {
55
return ++a;
66
},
77
sum: function(a, b) {
@@ -20,11 +20,14 @@ const obj1 = {
2020
}
2121
};
2222

23-
console.log('obj1.f1.name = ' + obj1.f1.name);
23+
console.log('obj1.fn1.name = ' + obj1.fn1.name);
2424
console.log('obj1.sum.name = ' + obj1.sum.name);
25+
console.log('obj1.inc.name = ' + obj1.inc.name);
2526
console.log('obj1.max.name = ' + obj1.max.name);
27+
console.log('obj1.min.name = ' + obj1.min.name);
28+
console.log('obj1.dec.name = ' + obj1.dec.name);
2629

27-
console.log('obj1.f1(5) = ' + obj1.f1(5));
30+
console.log('obj1.fn1(5) = ' + obj1.fn1(5));
2831
console.log('obj1.sum(1, 3) = ' + obj1.sum(1, 3));
2932
console.log('obj1.max(8, 6) = ' + obj1.max(8, 6));
3033

JavaScript/9-this.js

+4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ const city = {
88
},
99
f2: () => {
1010
return this.name;
11+
},
12+
f3() {
13+
return this.name;
1114
}
1215
};
1316

1417
console.log('city.f1() = ' + city.f1());
1518
console.log('city.f2() = ' + city.f2());
19+
console.log('city.f3() = ' + city.f3());

JavaScript/b-call-apply.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ function f1(a, b) {
77
f1(2, 3);
88
f1.call(null, 2, 3);
99

10-
f1(...[2, 3]);
11-
f1.apply(null, [2, 3]);
10+
const arr = [2, 3];
11+
f1(...arr);
12+
f1.apply(null, arr);

0 commit comments

Comments
 (0)