-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path06.boolean.js
More file actions
34 lines (30 loc) · 852 Bytes
/
06.boolean.js
File metadata and controls
34 lines (30 loc) · 852 Bytes
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
// 15.6.4 Properties of the Boolean Prototype Object
// 15.6.4.2 Boolean.prototype.toString ( )
Boolean.prototype.toString = function () {
// Step 2-4
var b = Boolean.prototype.valueOf.call(this);
// Step 5
if (b) {
return "true";
} else {
return "false";
}
};
@NoConstructor(Boolean.prototype.toString);
// 15.6.4.3 Boolean.prototype.valueOf ( )
Boolean.prototype.valueOf = function () {
var b;
// Step 2
if (typeof this === 'boolean') {
b = this;
// Step 3
} else if (@IsObject(this) && @GetInternalProperty(this, "Class") === "Boolean") {
b = @GetInternalProperty(this, "PrimitiveValue");
// Step 4
} else {
throw TypeError("Invalid arguments: Boolean.prototype.valueOf");
}
// Step 5
return b;
};
@NoConstructor(Boolean.prototype.valueOf);