CHALLENGE
function* rangeGenerator(start, end, step = 1) {
let current = start;
while (current <= end) {
yield current;
current += step;
}
}
const numbers = rangeGenerator(1, 10, 2);
numbers.next();
numbers.next();
const values = [...numbers];
console.log(values);
β€2
β€4π4π₯3
CHALLENGE
const obj = {
name: 'Taylor',
greet() {
return `Hello, ${this.name}!`;
},
delayedGreet() {
setTimeout(function() {
console.log(this.greet());
}, 100);
}
};
obj.delayedGreet();
β€4π1
What is the output?
Anonymous Quiz
54%
Hello, Taylor!
20%
TypeError: Cannot read properties of undefined (reading 'name')
18%
TypeError: this.greet is not a function
8%
undefined
β€7
CHALLENGE
function createCounter() {
let count = 0;
function increment() {
count += 1;
return count;
}
function decrement() {
count -= 1;
return count;
}
return { increment, decrement, value: () => count };
}
const counter = createCounter();
counter.increment();
counter.increment();
counter.decrement();
console.log(counter.value() + counter.increment());
β€4
What is the output?
Anonymous Quiz
16%
undefined
39%
2 + function increment() { count += 1; return count; }
16%
4
29%
3
β€3π3π€£2π€1
Vercel has acquired the company that caretakes the Nuxt project and employs some of its core team β a move Vue creator Evan You is quite optimistic about. Vercel now manages, or at least supports, several key projects like Next.js, Turborepo, Svelte, and shadcn/ui. Nuxt itself remains open source and has a promising future. Vercelβs Guillermo Rauch shares a little more about the move here.
NuxtLabs / Vercel
Please open Telegram to view this post
VIEW IN TELEGRAM
β€8π1π₯1
CHALLENGE
const memoryLeak = () => {
const cache = new Map();
const weakCache = new WeakMap();
const objKey = { id: 123 };
const data = { name: 'User data', value: 42 };
cache.set(objKey, data);
weakCache.set(objKey, data);
// Simulate removing reference to key
const result = { map: cache.has(objKey), weakMap: weakCache.has(objKey) };
// objKey = null; // This would be an error, as const can't be reassigned
return result;
};
console.log(memoryLeak());
β€6π€2
What is the output?
Anonymous Quiz
22%
{ map: false, weakMap: false }
32%
ReferenceError: objKey is not defined
23%
{ map: true, weakMap: false }
23%
{ map: true, weakMap: true }
β€5π1π₯1
CHALLENGE
function createCounter() {
let count = 0;
return {
increment() {
return ++count;
},
reset() {
const oldCount = count;
count = 0;
return oldCount;
}
};
}
const counterA = createCounter();
const counterB = createCounter();
counterA.increment();
counterA.increment();
counterB.increment();
const result = counterA.reset() + counterB.reset();
console.log(result);
β€3
β€5
This sounds like basic stuff, but James always does a good job of digging in and explaining things in a way that gives you a more nuanced way to think about a concept, even if itβs just βWhich function declaration syntax should I use?β
James Sinclair
Please open Telegram to view this post
VIEW IN TELEGRAM
π7β€2π₯1
CHALLENGE
const users = [
{ id: 1, name: 'Sarah' },
{ id: 2, name: 'Miguel' },
{ id: 3, name: 'Jordan' }
];
const activeUsers = new WeakSet();
activeUsers.add(users[0]);
activeUsers.add(users[2]);
users.splice(1, 1); // Remove Miguel
let count = 0;
for (const user of users) {
if (activeUsers.has(user)) count++;
}
console.log(count);
β€5π₯2
What is the output?
Anonymous Quiz
50%
2
28%
1
12%
ReferenceError: users is not defined
10%
TypeError: activeUsers.has is not a function
π₯1
A vanilla JS library for making on-page tours and contextual help systems. Itβs been around for several years, but is still maintained, and there are lots of examples to check out β itβs really smooth.
Kamran Ahmed
Please open Telegram to view this post
VIEW IN TELEGRAM
π3β€2π₯2
CHALLENGE
function mystery() {
try {
console.log('A');
throw new Error('Oops');
console.log('B');
} catch (err) {
console.log('C');
return 'D';
} finally {
console.log('E');
return 'F';
}
console.log('G');
return 'H';
}
console.log(mystery());
β€5
π€£6π3β€2π€2
The Ultimate Guide to Understanding EventLoop in Node.js
This comprehensive guide is going to take some time to cover every detail that you need to know, so grab a cup of coffee and settle in for an exciting journey to the fascinating world of Node.js. Letβs get started!
nairihar
Please open Telegram to view this post
VIEW IN TELEGRAM
β€8π2π₯2
CHALLENGE
const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);
const addTwo = num => num + 2;
const multiplyByThree = num => num * 3;
const subtractTen = num => num - 10;
const calculate = compose(subtractTen, multiplyByThree, addTwo);
console.log(calculate(5));
β€5π₯3π1
What is the output?
Anonymous Quiz
10%
7
44%
11
37%
((5 + 2) * 3) - 10 = 11
9%
(5 + 2) * 3 - 10 = 11
β€4π€3π2