Skip to content

Commit bb6ef84

Browse files
committed
Improve examples
1 parent 11cc0c9 commit bb6ef84

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

JavaScript/3-scalar.js

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

33
const scalar = 5;
4-
const object1 = { scalar };
4+
const object1 = { field: scalar };
55
const object2 = object1;
66

77
console.dir({ object1 });
88
console.dir({ object2 });
99
console.dir({ scalar });
1010

11-
object1.scalar = 6;
11+
object1.field = 6;
1212

1313
console.dir({ object1 });
1414
console.dir({ object2 });

JavaScript/4-types.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ o.city = 'Odessa';
1717
const a = ['Athens', 'Roma', 'London', 'Beijing', 'Kiev', 'Riga'];
1818

1919
a.push('Odessa');
20+
a.unshift('New York');
21+
22+
console.log('shifted:' + a.shift());
23+
console.log('pop: ' + a.pop());
2024

2125
console.log({ i }, typeof(i));
2226
console.log({ s }, typeof(s));

JavaScript/5-undefined-null-NaN.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ console.log({ u }, typeof(u));
77

88
// null
99

10-
let o = null;
10+
const o = null;
1111
console.log({ o }, typeof(o));
1212

1313
// NaN
@@ -16,6 +16,9 @@ let n = NaN;
1616
console.log({ n }, typeof(n));
1717

1818
n = undefined + 1;
19-
console.log({ n }, typeof(n));
19+
console.log(n);
2020

2121
console.log(Infinity, -Infinity, typeof(Infinity));
22+
23+
const s = o === null ? 'o is null' : 'o is not null';
24+
console.log(s);

0 commit comments

Comments
 (0)