Nodeβs release lines are shifting a little lately β v18 has gone EOL and now v23 gives way to v24 as the βCurrentβ release for when you need the cutting edge features. It comes with npm 11, V8 13.6 (hello
RegExp.escape
, Float16Array
, and `Error.isError`), the URLPattern API exposed by default, plus Undici 7.Node.js Team
Please open Telegram to view this post
VIEW IN TELEGRAM
π12β€1π₯1
CHALLENGE
const a = 9007199254740991n; // MAX_SAFE_INTEGER as BigInt
const b = 2n;
const c = a + b;
const result = [
a === 9007199254740991,
a + 1n === 9007199254740992n,
typeof c,
c > Number.MAX_SAFE_INTEGER,
BigInt(9007199254740992) - BigInt(9007199254740991)
];
console.log(result);
π€£4β€3π2π€2
What is the output?
Anonymous Quiz
21%
[false, true, 'object', true, 1n]
30%
[true, true, 'bigint', true, 1n]
27%
[false, true, 'bigint', true, 1n]
21%
[false, true, 'bigint', true, 1]
π7β€3π€2
CHALLENGE
const team = {
name: 'Eagles',
players: ['Smith', 'Johnson', 'Williams'],
coach: { name: 'Brown', experience: 12 },
stats: { wins: 10, losses: 6 }
};
const {
name: teamName,
players: [firstPlayer, , thirdPlayer],
coach: { name },
stats: { wins, draws = 0 }
} = team;
console.log(`${teamName}-${firstPlayer}-${thirdPlayer}-${name}-${wins}-${draws}`);
π5π€£5β€1
What is the output?
Anonymous Quiz
22%
undefined-Smith-Williams-Brown-10-0
30%
Eagles-Smith-Williams-Brown-10-undefined
38%
Eagles-Smith-Williams-Brown-10-0
10%
Eagles-Smith-undefined-Brown-10-0
β€9π3π₯2π€£2
CHALLENGE
const user = {
name: "Alice",
age: 32,
role: "developer"
};
const handler = {
get(target, prop) {
return prop in target ?
`Value: ${target[prop]}` :
"Not found";
}
};
const proxy = new Proxy(user, handler);
delete user.age;
console.log(Reflect.get(proxy, "name") + ", " + proxy.age + ", " + proxy.skills);
π4
What is the output?
Anonymous Quiz
25%
Alice, undefined, Not found
34%
Value: Alice, Value: undefined, Not found
29%
Value: Alice, Not found, Not found
12%
Value: Value: Alice, Not found, Not found
π4π€4
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£34π€5π4
CHALLENGE
const weakSet = new WeakSet();
let obj1 = { id: 1 };
let obj2 = { id: 2 };
let obj3 = obj1;
weakSet.add(obj1);
weakSet.add(obj2);
const results = [
weakSet.has(obj1),
weakSet.has(obj3),
weakSet.has({ id: 2 }),
weakSet.has(obj2)
];
obj1 = null;
console.log(results);
β€3π1π€©1
What is the output?
Anonymous Quiz
37%
[true, true, false, true]
33%
[true, false, false, true]
21%
[false, true, false, true]
9%
[true, true, true, false]
β€11π3π₯2π€1
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£7π6β€3π₯1π€©1
CHALLENGE
console.log(1);
setTimeout(() => {
console.log(2);
Promise.resolve().then(() => console.log(3));
}, 0);
Promise.resolve()
.then(() => {
console.log(4);
setTimeout(() => console.log(5), 0);
})
.then(() => console.log(6));
console.log(7);
1π2π€©1
What is the output?
Anonymous Quiz
22%
1, 7, 4, 6, 2, 5, 3
33%
1, 7, 4, 2, 6, 3, 5
35%
1, 7, 4, 6, 2, 3, 5
11%
1, 4, 7, 6, 2, 3, 5
π6β€3π₯1
CHALLENGE
const user = { name: 'Alice' };
const ratings = new WeakMap();
ratings.set(user, 5);
const result = [];
result.push(ratings.has(user));
result.push(ratings.get(user));
// Create a reference-free object
let tempUser = { name: 'Bob' };
ratings.set(tempUser, 10);
result.push(ratings.has(tempUser));
// Remove the reference
tempUser = null;
// Try to iterate through WeakMap
result.push(typeof ratings[Symbol.iterator]);
console.log(result);
π₯5β€1
What is the output?
Anonymous Quiz
28%
[true, 5, true, 'undefined']
33%
[true, 5, false, 'undefined']
25%
[true, 5, true, 'function']
14%
[true, 5, true, undefined]
π₯5β€1π1π€©1
CHALLENGE
function processTransaction(amount) {
try {
if (typeof amount !== 'number') {
throw new TypeError('Amount must be a number');
}
if (amount <= 0) {
throw new RangeError('Amount must be positive');
}
return 'Transaction processed';
} catch (error) {
if (error instanceof TypeError) {
return { status: 'Type Error', message: error.message };
} else if (error instanceof RangeError) {
return { status: 'Range Error', message: error.message };
}
return { status: 'Unknown Error', message: error.message };
}
}
console.log(processTransaction(-50));
π4π€©1
What is the output?
Anonymous Quiz
21%
Transaction processed
35%
RangeError: Amount must be positive
23%
{ status: 'Type Error', message: 'Amount must be a number' }
21%
{ status: 'Range Error', message: 'Amount must be positive' }
π10β€2π₯1π€©1
CHALLENGE
function modify(obj) {
obj.a.push(4);
obj.b = 'changed';
return obj;
}
const original = { a: [1, 2, 3], b: 'original', c: { deep: true } };
const copy1 = { ...original };
const copy2 = JSON.parse(JSON.stringify(original));
modify(copy1);
console.log(original.a, original.b, copy2.c === original.c);
π5β€1π€©1
What is the output?
Anonymous Quiz
27%
[1, 2, 3] 'original' true
29%
[1, 2, 3] 'original' false
23%
[1, 2, 3, 4] 'original' false
21%
[1, 2, 3, 4] 'changed' false
π9β€2π₯1