CHALLENGE
const num1 = 9007199254740992n;
const num2 = 1n;
const result1 = num1 + num2;
const result2 = Number(num1) + Number(num2);
const result3 = num1 + BigInt(1);
const result4 = String(num1) + String(num2);
console.log(typeof result2 === typeof result1, result1 === result3, result4);
๐2
What is the output?
Anonymous Quiz
27%
false false "90071992547409921"
30%
true true "90071992547409921"
27%
false true 9007199254740993n
16%
false true "90071992547409921"
๐6โค4๐ฅ2
๐ต๏ธ ๐ช๐ฒ ๐ฐ๐ฎ๐๐ด๐ต๐ ๐ฐ๐ต๐๐ฎ๐๐ฎ๐ฟ๐๐ ๐๐ฎ๐ฐ๐ธ๐ถ๐ป๐ด ๐๐ฟ๐ผ๐๐ฝ ๐ฑ๐ฒ๐ฏ๐๐ด๐ด๐ถ๐ป๐ด ๐๐ต๐ฒ๐ถ๐ฟ ๐ผ๐๐ป ๐บ๐ฎ๐น๐๐ฎ๐ฟ๐ฒ... ๐ถ๐ป ๐ฟ๐ฒ๐ฎ๐น ๐๐ถ๐บ๐ฒ.
A couple of weeks ago, something unexpected happened. While monitoring malicious uploads to the NPM ecosystem, we stumbled on a suspicious package: react-html2pdf.js (now suspended). At first glance, it looked innocuous. ๐ก๐ผ ๐น๐ถ๐ณ๐ฒ๐ฐ๐๐ฐ๐น๐ฒ ๐ต๐ผ๐ผ๐ธ๐. ๐ก๐ผ ๐ผ๐ฏ๐๐ถ๐ผ๐๐ ๐บ๐ฎ๐น๐๐ฎ๐ฟ๐ฒ. Just a basic function in the index.js file.
Mackenzie Jackson
A couple of weeks ago, something unexpected happened. While monitoring malicious uploads to the NPM ecosystem, we stumbled on a suspicious package: react-html2pdf.js (now suspended). At first glance, it looked innocuous. ๐ก๐ผ ๐น๐ถ๐ณ๐ฒ๐ฐ๐๐ฐ๐น๐ฒ ๐ต๐ผ๐ผ๐ธ๐. ๐ก๐ผ ๐ผ๐ฏ๐๐ถ๐ผ๐๐ ๐บ๐ฎ๐น๐๐ฎ๐ฟ๐ฒ. Just a basic function in the index.js file.
Mackenzie Jackson
๐ค6๐คฃ6โค2
CHALLENGE
function createSymbolDemo() {
const obj = {};
const sym1 = Symbol('description');
const sym2 = Symbol('description');
const sym3 = Symbol.for('shared');
const sym4 = Symbol.for('shared');
obj[sym1] = 'Value 1';
obj[sym2] = 'Value 2';
obj[sym3] = 'Value 3';
obj[sym4] = 'Value 4';
console.log(Object.keys(obj).length, sym1 === sym2, sym3 === sym4, obj[sym3]);
}
createSymbolDemo();
๐6
What is the output?
Anonymous Quiz
21%
0 false true Value 4
31%
4 true true Value 4
35%
4 false false Value 3
13%
0 false true Value 3
๐ค9๐3โค2
Please open Telegram to view this post
VIEW IN TELEGRAM
๐คฃ55โค5๐คฉ4๐2
CHALLENGE
function* generateSequence() {
let i = 1;
while (i <= 3) {
yield i++;
}
}
function* extendSequence() {
yield* generateSequence();
yield* [4, 5];
yield 6;
}
const generator = extendSequence();
const result = [];
for (const value of generator) {
if (value % 2 === 0) {
result.push(value * 2);
} else {
result.push(value);
}
}
console.log(result);
โค1
What is the output?
Anonymous Quiz
15%
[1, 4, 3, 8, 5, 6]
44%
[1, 4, 3, 8, 5, 12]
28%
[1, 2, 3, 4, 5, 6]
13%
[1, 4, 3, 8, 10, 12]
๐6๐ฅ5โค2๐ค1
Nodeโs Fastify framework has a mature plugin for Vite integration (explained in detail here), including @fastify/react which just hit version 1.0 and makes it easy to create fast, featureful (though obviously less so than Next.js) React apps atop Fastify. How fast? Very, it seems.
Jonas Galvez
Please open Telegram to view this post
VIEW IN TELEGRAM
๐ค6โค3๐2๐ฅ1
CHALLENGE
const privateData = new WeakMap();
function Person(name) {
privateData.set(this, { name, secretCount: 0 });
this.greet = function() {
const data = privateData.get(this);
data.secretCount++;
return `Hello, my name is ${data.name}`;
};
this.getSecretCount = function() {
return privateData.get(this).secretCount;
};
}
const alice = new Person('Alice');
alice.greet();
alice.greet();
const result = [
privateData.has(alice),
alice.name,
alice.getSecretCount()
];
console.log(result);
๐4โค1
What is the output?
Anonymous Quiz
31%
[true, undefined, 2]
27%
[false, undefined, 2]
16%
[Object, undefined, 2]
26%
[true, 'Alice', 2]
1๐5โค2๐ฅ1
Node actually has a mechanism for creating single executable applications and there are numerous other tools to do it, but Lexe takes the approach of using Amazonโs lightweight LLRT engine to make binaries of under 10MB in size. Note, however, "Lexe is not a drop-in replacement for Node.js. It only supports a subset of Node.js APIs."
Ray-D-Song
Please open Telegram to view this post
VIEW IN TELEGRAM
๐6โค3๐ฅ1
Please open Telegram to view this post
VIEW IN TELEGRAM
2๐คฃ37โค4๐ฅ4๐1
CHALLENGE
const user = {
name: 'Alice',
age: 30
};
const handler = {
get(target, prop) {
if (prop in target) {
return target[prop];
}
return `Property '${prop}' doesn't exist`;
},
set(target, prop, value) {
if (prop === 'age' && typeof value !== 'number') {
console.log('Age must be a number');
return false;
}
target[prop] = value;
return true;
}
};
const proxy = new Proxy(user, handler);
proxy.age = '32';
proxy.age = 32;
console.log(proxy.job);
๐7โค3
What is the output?
Anonymous Quiz
20%
undefined
45%
Age must be a number Property 'job' doesn't exist
19%
Age must be a number
16%
Property 'job' doesn't exist
๐3โค2๐ฅ2
Please open Telegram to view this post
VIEW IN TELEGRAM
๐คฃ45๐12โค2๐ฅ1๐ค1
CHALLENGE
function executePromises() {
console.log(1);
setTimeout(() => {
console.log(2);
}, 0);
Promise.resolve().then(() => {
console.log(3);
setTimeout(() => {
console.log(4);
}, 0);
}).then(() => {
console.log(5);
});
console.log(6);
}
executePromises();
๐ฅ3โค2๐1
What is the output?
Anonymous Quiz
23%
1, 6, 3, 2, 5, 4
25%
1, 6, 2, 3, 5, 4
24%
1, 3, 5, 6, 2, 4
28%
1, 6, 3, 5, 2, 4
๐6๐คฉ5โค2๐ฅ1
Several years in the making, the record and tuples proposal offered two new deeply immutable data structures to JavaScript, but at this weekโs TC39 meeting, the consensus was to drop it.
Please open Telegram to view this post
VIEW IN TELEGRAM
๐7๐ค4๐คฃ3โค2๐ฅ1
CHALLENGE
function main() {
console.log(1);
setTimeout(() => console.log(2), 0);
Promise.resolve().then(() => {
console.log(3);
setTimeout(() => console.log(4), 0);
}).then(() => console.log(5));
Promise.resolve().then(() => console.log(6));
console.log(7);
}
main();
โค5๐2