-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path3-elements.js
More file actions
77 lines (66 loc) · 1.49 KB
/
3-elements.js
File metadata and controls
77 lines (66 loc) · 1.49 KB
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
'use strict';
{
// PACKED_SMI_ELEMENTS
const array = [1, 2, 3]; // number[] smi[]
console.log(array);
}
{
// PACKED_DOUBLE_ELEMENTS
const array = [1, 2, 3, 4 / 3]; // double[]
console.log(array);
}
{
// PACKED_DOUBLE_ELEMENTS
const array = [1, 2, 3]; // smi[]
array.push(4 / 3); // smi[] -> double[]
// [1.0, 2.0, 3.0, 1.3333333333333333]
console.log(array);
}
{
// PACKED_ELEMENTS
const array = [1, 2, 3, 'hello']; // object[]
// [Number(1), Number(2), Number(3), String('hello')]
console.log(array);
}
{
// PACKED_ELEMENTS
const array = [1, 2, 3]; // smi[]
array.push('hello'); // smi[] -> object[]
// [Number(1), Number(2), Number(3), String('hello')]
console.log(array);
}
{
// HOLEY_SMI_ELEMENTS
const array = [1, 2, 3, , , 4];
console.log(array);
}
{
// HOLEY_SMI_ELEMENTS
const array = [1, 2, 3];
array[100] = 4; // smi[] -> holey smi[]
console.log(array);
}
{
// HOLEY_DOUBLE_ELEMENTS
const array = [1, 2, 3, , , 4 / 3];
console.log(array);
}
{
// HOLEY_DOUBLE_ELEMENTS
const array = [1, 2, 3];
array[100] = 4 / 3; // smi[] -> holey double[]
console.log(array);
}
{
// HOLEY_ELEMENTS
const array = [1, 2, 3, , , 'hello']; // object[]
// [Number(1), Number(2), Number(3), <2 empty items>, String('hello')]
console.log(array);
}
{
// HOLEY_ELEMENTS
const array = [1, 2, 3]; // smi[]
array[100] = 'hello'; // smi[] -> holey object[]
// [Number(1), Number(2), Number(3), <97 empty items>, String('hello')]
console.log(array);
}