-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-types.js
81 lines (56 loc) · 1.22 KB
/
01-types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// 1. number (= double, IEEE 754)
x = 42;
x = 3.14;
x = 42 / 0; // => Infinity
x = 42 / -0; // => -Infinity
x = 0.1 + 0.2; // => *nicht* 0.3
x = 0xff_a7_de_5c_ab_37;
x = 0o123;
x = 0b1100_1011;
x = 10_000_000_000_000;
x = Number.MAX_VALUE;
x = Number.MAX_SAFE_INTEGER;
x = 123437564837645834658436858734658764387n; // BigInt
// 2. string
x = '';
x = 'a';
x = 'abc';
x = "abc";
x = `abc`;
protocol = 'https';
x = `the native web GmbH
${protocol}://www.thenativeweb.io`;
// 3. boolean
x = true;
x = false;
// 4. undefined
x = undefined;
// 5. function
x = function () {
// ...
};
// 6. object
var person = {
firstName: "Donald",
lastName: "Duck",
getFullName: function () {
return "Donald Duck";
}
};
console.log(person.FirstName); // => undefined
person.FirstName = 'Dagobert';
console.log(person.FirstName); // => Dagobert
var person = null;
// 7. null (=> object)
x = null;
// 8. Symbol
x = Symbol('foo');
y = Symbol('foo');
// x und y sind nicht identisch!
// Variablen
'use strict';
x = 'foo'; // => globale Variable
var x = 'foo'; // => lokale Variable, nicht mehr verwenden!
let x = 'foo'; // => lokale Variable
const x = 'foo'; // => lokale Konstante
// => const > let > var