Repository navigation
Expand file tree
/
Copy pathsimple.js
More file actions
58 lines (43 loc) · 1.54 KB
/
Copy pathsimple.js
File metadata and controls
58 lines (43 loc) · 1.54 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
if (performance.memory) { console.log("Used JS Heap Size:", performance.memory.usedJSHeapSize); console.log("Total JS Heap Size:", performance.memory.totalJSHeapSize); console.log("JS Heap Size Limit:", performance.memory.jsHeapSizeLimit);
} else { console.log("Memory API not supported."); }
const memoryStore = {};
memoryStore.username = "Marvel Manuza Gulane && coderlava / Coderlava && Grace Manuza Gulane ";
memoryStore.age = 25;
console.log(memoryStore);
const data = [];
setInterval(() => {
data.push(new Array(100000).fill("memory"));
console.log(`Stored arrays: ${data.length}`);
}, 1000);
function randomHex(length = 8) {
const chars = "0123456789abcdef";
let result = "";
for (let i = 0; i < length; i++) {
result += chars[Math.floor(Math.random() * chars.length)];
}
return result;
}
function textToHex(text) {
return Array.from(new TextEncoder().encode(text))
.map(byte => byte.toString(16).padStart(2, "0"))
.join("");
}
console.log(textToHex("Hello"));
// 48656c6c6f
function generateHexCode(bytes) {
return bytes
.map(byte => `0x${byte.toString(16).padStart(2, "0")}`)
.join(", ");
}
const data = [72, 101, 108, 108, 111];
console.log(generateHexCode(data));
// 0x48, 0x65, 0x6c, 0x6c, 0x6f
function toHexLiteral(num) {
return "0x" + num.toString(16).toUpperCase();
}
console.log(toHexLiteral(255));
// 0xFF
console.log(randomHex()); // e.g. "7fa2c4d1"
console.log(randomHex(16)); // e.g. "b93ef0c1a27d4e88"
const code = String(Math.floor(Math.random() * 1000)).padStart(3, '0');
console.log(code);