Skip to content

Commit 62d8340

Browse files
committed
Code style
1 parent 46625e6 commit 62d8340

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

JavaScript/1-simple.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ function inc(a) {
44
return ++a;
55
}
66

7-
let sum = function(a, b) {
7+
const sum = function(a, b) {
88
return a + b;
99
};
1010

11-
let max = (a, b) => {
12-
return a > b ? a : b;
13-
};
11+
const max = (a, b) => (a > b ? a : b);
1412

1513
console.log('inc(5) = ' + inc(5));
1614
console.log('sum(1, 3) = ' + sum(1, 3));

JavaScript/2-context.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
'use strict';
22

3-
let cities = ['Athens', 'Roma', 'London', 'Beijing', 'Kiev', 'Riga'];
4-
let f = s => s.length;
3+
const cities = ['Athens', 'Roma', 'London', 'Beijing', 'Kiev', 'Riga'];
4+
const f = s => s.length;
55

66
function f1() {
7-
let cities = ['Athens', 'Roma'];
8-
let f = s => s.toUpperCase();
7+
const cities = ['Athens', 'Roma'];
8+
const f = s => s.toUpperCase();
99
console.dir({ cities });
1010
console.dir(cities.map(f));
1111

1212
{
13-
let f = s => s.toLowerCase();
13+
const f = s => s.toLowerCase();
1414
console.dir({ cities });
1515
console.dir(cities.map(f));
1616
}
1717

1818
{
19-
let cities = ['London', 'Beijing', 'Kiev'];
19+
const cities = ['London', 'Beijing', 'Kiev'];
2020
console.dir({ cities });
2121
console.dir(cities.map(f));
2222
}

JavaScript/3-abstraction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22

3-
let power = Math.pow;
4-
let square = x => power(x, 2);
5-
let cube = x => power(x, 3);
3+
const power = Math.pow;
4+
const square = x => power(x, 2);
5+
const cube = x => power(x, 3);
66

77
console.log(power(10, 2));
88
console.log(square(10));

JavaScript/4-introspection.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ function inc(a) {
44
return ++a;
55
}
66

7-
let sum = function(a, b) {
7+
const sum = function(a, b) {
88
return a + b;
99
};
1010

11-
let max = (a, b) => {
12-
return a > b ? a : b;
13-
};
11+
const max = (a, b) => (a > b ? a : b);
1412

1513
console.log('Names: ');
1614
console.dir({

JavaScript/6-spread.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3-
let f1 = (...args) => console.log(args);
3+
const f1 = (...args) => console.log(args);
44

55
f1(1, 2, 3);
66

7-
let f2 = (...args) => {
7+
const f2 = (...args) => {
88
args.forEach(arg => {
99
if (typeof(arg) === 'object') {
1010
console.log(typeof(arg) + ': ' + JSON.stringify(arg));

JavaScript/7-new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
let sum = new Function('a, b', 'return a + b');
3+
const sum = new Function('a, b', 'return a + b');
44

55
console.dir({
66
name: sum.name,

JavaScript/8-method.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
'use strict';
22

3-
let obj1 = {
3+
const obj1 = {
44
f1: function inc(a) {
55
return ++a;
66
},
77
sum: function(a, b) {
88
return a + b;
99
},
10+
inc(a) {
11+
return ++a;
12+
},
1013
max: (a, b) => {
1114
return a > b ? a : b;
12-
}
15+
},
16+
min: (a, b) => (a < b ? a : b)
1317
};
1418

1519
console.log('obj1.f1.name = ' + obj1.f1.name);

JavaScript/9-this.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
let city = {
3+
const city = {
44
name: 'Kiev',
55
year: 482,
66
f1: function() {

0 commit comments

Comments
 (0)