-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoNumber.js
49 lines (34 loc) · 818 Bytes
/
toNumber.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
// i want to implement the ToNumber abstraction operation on subtract operator
// console.log(1-undefined);
// console.log(1-null);
// console.log(1-true);
// console.log(undefined - null);
// console.log(null-false);
// console.log(undefined - true);
// console.log(null-true);
console.log(1-Object);
function Abstract(n)
{
let x = !n;
console.log(x);
}
Abstract(undefined);
Abstract(null);
Abstract(-4);
Abstract(-0);
Abstract("");
Abstract(Symbol);
console.log(1 == false);
console.log(undefined == false);
console.log(undefined == true);
console.log(NaN === NaN);
let obj = { x: 4 , toString() {return 100;}}
console.log(99 === obj);
console.log(100 === obj);
let obj1 = {
x : 4 , valueOf(){
return 4;
}
}
console.log(obj1.valueOf());
console.log(obj1.toString());