CHALLENGE
class VideoCall {
constructor() {
this.pc = { iceConnectionState: 'new' };
this.streams = [];
}
async connect() {
this.pc.iceConnectionState = 'checking';
await Promise.resolve();
this.pc.iceConnectionState = 'connected';
this.streams.push('remote-video');
return this.pc.iceConnectionState;
}
handleConnectionChange() {
const states = ['new', 'checking', 'connected'];
return states.map(state => {
return this.pc.iceConnectionState === state ? `Status: ${state}` : null;
}).filter(Boolean);
}
}
const call = new VideoCall();
call.connect().then(() => {
console.log(call.handleConnectionChange());
});
❤6
What is the output?
Anonymous Quiz
27%
['Status: connected', 'Status: checking', 'Status: new']
15%
[]
38%
['Status: new', 'Status: checking', 'Status: connected']
20%
['Status: connected']
❤6👍4🔥3
Wrapping around an (included) Swift-powered binary, this captures Mac system audio output and emits it as PCM encoded chunks at regular intervals. GitHub repo.
Nick Payne
Please open Telegram to view this post
VIEW IN TELEGRAM
❤3👍2🔥1
CHALLENGE
const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);
const addPrefix = str => `prefix_${str}`;
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1);
const addSuffix = str => `${str}_suffix`;
const process = compose(addSuffix, capitalize, addPrefix);
console.log(process('data'));
❤3
What is the output?
Anonymous Quiz
34%
prefix_Data_suffix
31%
prefix_data_suffix
17%
data_suffix
18%
Prefix_data_suffix
❤5👍2🔥2
Please open Telegram to view this post
VIEW IN TELEGRAM
1❤1🔥1
CHALLENGE
const Flyable = {
fly() { return `${this.name} is flying`; }
};
const Swimmable = {
swim() { return `${this.name} is swimming`; }
};
function createDuck(name) {
return Object.assign({ name }, Flyable, Swimmable);
}
const duck = createDuck('Quackers');
console.log(duck.fly());
console.log(duck.swim());
console.log(Object.getOwnPropertyNames(duck));
❤3
What is the output?
Anonymous Quiz
21%
undefined is flying undefined is swimming [ 'name', 'fly', 'swim' ]
48%
Quackers is flying Quackers is swimming [ 'name', 'fly', 'swim' ]
21%
Quackers is flying Quackers is swimming [ 'fly', 'swim', 'name' ]
10%
Quackers is flying Quackers is swimming [ 'name' ]
🔥5❤3👍3
CHALLENGE
class Logger {
constructor(prefix) {
this.prefix = prefix;
}
log(message) {
console.log(`${this.prefix}: ${message}`);
}
}
class Database {
constructor(logger) {
this.logger = logger;
}
save(data) {
this.logger.log(`Saving ${data}`);
return `${data}_saved`;
}
}
const logger = new Logger('DB');
const db = new Database(logger);
const result = db.save('user');
console.log(result);
1❤8👍2
What is the output?
Anonymous Quiz
19%
user_saved DB: Saving user
53%
DB: Saving user user_saved
18%
DB: Saving user user
10%
Saving user user_saved
🔥3❤2👍1
CHALLENGE
const target = { name: 'Sarah', age: 25 };
const handler = {
get(obj, prop) {
if (prop in obj) {
return obj[prop];
}
return `Property '${prop}' not found`;
},
set(obj, prop, value) {
obj[prop] = value.toString().toUpperCase();
return true;
}
};
const proxy = new Proxy(target, handler);
proxy.city = 'boston';
console.log(proxy.name);
console.log(proxy.city);
console.log(proxy.country);
❤3🔥2
The V8 team has made JSON.stringify over twice as fast, giving your apps an automatic performance boost for common tasks like API responses and caching, at least once Node upgrades to V8 13.8 (Node 24 uses V8 13.6). This article unpacks the low-level work behind the speedup.
Patrick Thier (V8)
Please open Telegram to view this post
VIEW IN TELEGRAM
❤9🔥4👍2
CHALLENGE
class Counter {
constructor(max) {
this.max = max;
}
*[Symbol.iterator]() {
let current = 0;
while (current < this.max) {
yield current++;
}
}
}
const counter = new Counter(3);
const result = [...counter, ...counter];
console.log(result);
❤5
What is the output?
Anonymous Quiz
25%
[0, 1, 2]
55%
[0, 1, 2, 0, 1, 2]
10%
[]
10%
[0, 0, 1, 1, 2, 2]
❤3🔥3
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4👍4🔥1
CHALLENGE
const numbers = [1, 2, 3, 4, 5];
const result = numbers
.map(n => n * 2)
.filter(n => n > 5)
.reduce((acc, n, index) => {
acc.sum += n;
acc.indices.push(index);
return acc;
}, { sum: 0, indices: [] });
console.log(result.sum);
console.log(result.indices);
🤔10❤3
What is the output?
Anonymous Quiz
26%
18 [2, 3, 4]
34%
18 [0, 1, 2]
28%
20 [0, 1, 2]
12%
20 [2, 3, 4]
🤔25❤4
Sorry for the confusion earlier! The correct answer is actually 24, not 18.
After mapping and filtering, we get
Thanks Fabricio for the note
After mapping and filtering, we get
[6, 8, 10]
, and summing them gives 6 + 8 + 10 = 24
.Thanks Fabricio for the note
👍18🤣11🔥4❤1🤩1