-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
6-parse.js
81 lines (66 loc) · 2.44 KB
/
6-parse.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
'use strict';
console.log(0b11); // 3
console.log(0o11); // 9
console.log(0x11); // 17
console.log(parseInt(5, 10)); // 5
console.log(parseInt('5', 10)); // 5
console.log(parseInt('+5', 10)); // 5
console.log(parseInt('5mm', 10)); // 5
console.log(parseInt('(5)', 10)); // NaN
console.log(parseInt('"5"', 10)); // NaN
console.log(parseInt('[5]', 10)); // NaN
console.log(parseInt('NaN', 10)); // NaN
console.log(parseInt(Infinity, 10)); // NaN
console.log(parseInt('Infinity', 10)); // NaN
console.log(parseInt('-Infinity', 10)); // NaN
console.log(5.1, parseInt(5.1, 10)); // 5.1 5
console.log(5.1 * 1e50, parseInt(5.1 * 1e50, 10)); // 5.1e+50 5
console.log(0.000000000005, parseInt(0.000000000005, 10)); // 5e-12 5
console.log(0.0000005, parseInt(0.0000005, 10)); // 5e-7 5
console.log(0.000005, parseInt(0.000005, 10)); // 0.000005 0
// 255
console.log(0xfF);
console.log(parseInt('0xff', 16));
console.log(parseInt('0xFf', 16));
console.log(parseInt(' 0xFf ', 16));
// NaN
console.log(parseInt('ff', 2));
console.log(parseInt('ff', 8));
console.log(parseInt('ff', 10));
console.log(parseInt('ff', 15));
console.log(0xff); // 255
console.log(parseInt('ff', 17)); // 270
console.log(parseInt('ff', 20)); // 315
console.log(parseInt('ff', 30)); // 465
console.log(parseInt('ff', 31)); // 480
console.log(parseInt('ff', 32)); // 495
console.log(parseInt('ff', 33)); // 510
console.log(parseInt('ff', 34)); // 525
console.log(parseInt('ff', 35)); // 540
console.log(parseInt('ff', 36)); // 555
console.log(parseInt('ff', 37)); // NaN
// 3.14
console.log(parseFloat(3.14));
console.log(parseFloat('3.14'));
console.log(parseFloat('314e-2'));
console.log(parseFloat('3.14text'));
console.log(parseFloat('0.0314E+2'));
// 5
console.log(parseFloat('5'));
console.log(parseFloat('5.0'));
console.log(parseFloat('5.0000000000000001'));
console.log(parseFloat('5.1')); // 5.1
console.log(parseFloat('5.000000000000001')); // 5.000000000000001
console.log(parseFloat('100')); // 100
console.log(parseFloat('-100')); // -100
console.log(parseFloat('+100')); // 100
console.log(parseFloat(5)); // 5
console.log(parseFloat('5')); // 5
console.log(parseFloat('+5')); // 5
console.log(parseFloat('5mm')); // 5
console.log(parseFloat('(5)')); // NaN
console.log(parseFloat('"5"')); // NaN
console.log(parseFloat('[5]')); // NaN
console.log(parseFloat('NaN')); // NaN
console.log(parseFloat('Infinity')); // Infinity
console.log(parseFloat('-Infinity')); // -Infinity