Telegram Web
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣12πŸ‘5❀3
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
πŸ˜†
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);
❀2πŸ‘1🀩1
❀10πŸ‘3πŸ”₯2πŸ€”1
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘6🀣6❀2πŸ”₯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🀩1
πŸ‘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
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
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
CHALLENGE

const result = (function() {
let count = 0;

return {
increment() {
return ++count;
},
get value() {
return count;
},
reset() {
const oldCount = count;
count = 0;
return oldCount;
}
};
})();

result.increment();
result.increment();
console.log(result.reset() + result.value + result.increment());
πŸ‘1
What is the output?
Anonymous Quiz
29%
3
30%
201
28%
2undefined1
14%
2
πŸ€”6❀3πŸ‘2πŸ”₯2
πŸ€” I Think the Ergonomics of Generators is Growing on Me

The author notes generator functions have been widely available in JavaScript for a long time, yet β€œtheir practicality hasn’t exactly caught on.” This is a great look at what they are and where they can be useful.

Alex MacArthur
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5🀣2πŸ”₯1
Media is too big
VIEW IN TELEGRAM
πŸ₯ƒ We often get feedback asking us to include answers to the quizzesβ€”but honestly, some of them need more explanation than a Marvel movie plot. It’s way better if you use Google or GPT to dig into the questions and uncover the answers like the true quiz detective you are!
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘13🀣7❀3πŸ”₯1🀩1
πŸ™ To continue delivering more exciting stories, we're kindly asking telegram premium users to help us (boost) take things to the next level.

We need 40 boosts 😭

https://www.tgoop.com/javascript?boost
Please open Telegram to view this post
VIEW IN TELEGRAM
1πŸ‘9❀3πŸ”₯2πŸ€”1
2025/07/12 20:01:35
Back to Top
HTML Embed Code: