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
20%
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);
❤4🔥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]
11%
[]
10%
[0, 0, 1, 1, 2, 2]
❤3🔥3
Please open Telegram to view this post
VIEW IN TELEGRAM
❤5👍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]
27%
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
CHALLENGE
function processData(data) {
try {
if (!data) {
throw new TypeError('Data is missing');
}
const result = data.process();
return result;
} catch (error) {
console.log(error instanceof ReferenceError ? 1 :
error instanceof TypeError ? 2 :
error instanceof SyntaxError ? 3 : 4);
}
}
processData(null);
👍4❤2
❤5👍4🔥3🤔1
Please open Telegram to view this post
VIEW IN TELEGRAM
👍5🤔4🔥3❤1
The popular, efficiency-focused package installer now lets you define Node.js, Deno or Bun versions in package.json and pnpm will then download and pin them automatically.
Zoltan Kochan
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7👍4🔥1
CHALLENGE
const obj = {
name: 'Sarah',
getName() {
return this.name;
},
getNameArrow: () => {
return this.name;
}
};
const getName = obj.getName;
const getNameArrow = obj.getNameArrow;
console.log(obj.getName());
console.log(getName());
console.log(getNameArrow());
console.log(obj.getNameArrow());
🤩2❤1🤔1