CHALLENGE β
setTimeout(() => console.log('Timeout 1'), 100);
setTimeout(() => {
console.log('Timeout 2');
Promise.resolve().then(() => console.log('Promise in Timeout 2'));
}, 50);
Promise.resolve().then(() => console.log('Promise 1'));
setTimeout(() => console.log('Timeout 3'), 150);
console.log('Sync');
Please open Telegram to view this post
VIEW IN TELEGRAM
π1
What is the output?
Anonymous Quiz
18%
Sync, Promise 1, Timeout 2, Timeout 1, Timeout 3, Promise in Timeout 2
26%
Sync, Timeout 2, Promise 1, Timeout 1, Promise in Timeout 2, Timeout 3
47%
Sync, Promise 1, Timeout 2, Promise in Timeout 2, Timeout 1, Timeout 3
9%
Sync, Promise 1, Timeout 1, Timeout 2, Promise in Timeout 2, Timeout 3
π11π₯6π€4β€2π€£1
The architects behind the development of the ECMAScript / JavaScript spec got together again this week (you can see them in this tweet) and they had a packed agenda. Import attributes, Iterator helpers, Promise.try and Regexp modifiers all made it to stage 4, and more besides.
Sarah Gooding (Socket)
Please open Telegram to view this post
VIEW IN TELEGRAM
π3β€2π₯2
CHALLENGE β
async function first() {
console.log('First Start');
await second();
console.log('First End');
}
async function second() {
console.log('Second Start');
}
console.log('Script Start');
first();
setTimeout(() => console.log('Timeout'), 0);
console.log('Script End');
Please open Telegram to view this post
VIEW IN TELEGRAM
β€3π1
What is the output?
Anonymous Quiz
23%
Script Start, First Start, Second Start, Script End, First End, Timeout
19%
First Start, Script Start, Second Start, Script End, First End, Timeout
39%
Script Start, First Start, Second Start, First End, Script End, Timeout
19%
Script Start, First Start, First End, Second Start, Script End, Timeout
1π€20π€£4π1
The code to lay out documents is verbose but thereβs a lot of functionality baked in and there arenβt many other options for this task. Hereβs a CodePen-based example to give you an idea. GitHub repo.
Dolan Miu
Please open Telegram to view this post
VIEW IN TELEGRAM
π3β€2π₯2
CHALLENGE β
const obj = Object.freeze({
name: "Alice",
info: {
age: 25
}
});
try {
obj.name = "Bob";
obj.info.age = 30;
} catch (e) {
console.log("Error:", e.message);
}
console.log(obj.name, obj.info.age);
Please open Telegram to view this post
VIEW IN TELEGRAM
π3
What is the output?
Anonymous Quiz
33%
Error: Cannot assign to read-only property 'name' -> Alice 25
23%
Error: Cannot assign to read-only property 'name' -> Bob 30
26%
Alice 30
17%
Bob 30
π€15π7β€3π€©2
Please open Telegram to view this post
VIEW IN TELEGRAM
π6π₯3β€1
CHALLENGE β
function* numberGenerator() {
let i = 0;
while (i < 3) {
yield i++;
}
}
const gen = numberGenerator();
console.log(gen.next().value);
console.log(gen.return(10).value);
console.log(gen.next().value);
Please open Telegram to view this post
VIEW IN TELEGRAM
π€©4π2π₯1
π€10π5β€2
CHALLENGE β
function processData({ a = 10, b = 20 } = { a: 30 }) {
console.log(a, b);
}
processData({ a: 5 });
processData();
Please open Telegram to view this post
VIEW IN TELEGRAM
π1
π€13π7π₯2π€£1
CHALLENGE β
const obj = {};
Object.defineProperty(obj, 'name', {
value: 'Alice',
writable: false,
configurable: false
});
try {
obj.name = 'Bob';
delete obj.name;
console.log(obj.name);
} catch (e) {
console.log('Error:', e.message);
}
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯3π1
Itβs been a quiet few weeks for official releases. This update marks one of the last in Node 20βs run as the active LTS release, and introduces experimental network inspection support. Node 22 will soon take over the active LTS crown (as per schedule) but what will its codename be given there are no elements starting with J? Amazingly, this question was asked six years ago and it's (probably) going to be Jod.
MichaΓ«l Zasso
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π4π₯2
CHALLENGE β
const map = new Map();
const key1 = {};
const key2 = key1;
map.set(key1, "Value for key1");
map.set(key2, "Value for key2");
console.log(map.get({}));
console.log(map.get(key1));
Please open Telegram to view this post
VIEW IN TELEGRAM
π3β€1
What is the output?
Anonymous Quiz
36%
undefined Value for key1
27%
undefined Value for key2
24%
Value for key2 Value for key2
14%
Value for key1 Value for key2
π₯8β€4π4π€£4