-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path2-primitives.js
More file actions
39 lines (36 loc) · 890 Bytes
/
2-primitives.js
File metadata and controls
39 lines (36 loc) · 890 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
35
36
37
38
39
'use strict';
{
const values = [5, Number(5), new Number(5)];
const output = values.map((value) => ({
type: typeof value,
ctr: value.constructor.name,
value,
instance: value instanceof Number,
primitive: value.valueOf(),
five: value === 5,
}));
console.table(output);
}
{
const values = ['text', String('text'), new String('text')];
const output = values.map((value) => ({
type: typeof value,
ctr: value.constructor.name,
value,
instance: value instanceof String,
primitive: value.valueOf(),
text: value === 'text',
}));
console.table(output);
}
{
const values = [true, Boolean(true), new Boolean(true)];
const output = values.map((value) => ({
type: typeof value,
ctr: value.constructor.name,
value,
instance: value instanceof Boolean,
primitive: value.valueOf(),
}));
console.table(output);
}