CHALLENGE
try {
const arr = [1, 2, 3];
function processArray() {
try {
nonExistentFunction();
} catch (err) {
throw new TypeError('Invalid type');
}
}
try {
processArray();
} catch (err) {
console.log(err instanceof Error, err instanceof TypeError, err.message);
}
} catch (finalError) {
console.log('Caught in outer block:', finalError);
}
What is the output?
Anonymous Quiz
28%
true true Invalid type
38%
true false 'nonExistentFunction is not defined'
22%
true true 'Invalid type'
13%
false true 'Invalid type'
A library to use the power of ANSI escape sequences for coloring and styling text in many environments including the terminal, Chromium-based browsers, Node, Bun, Deno, and even Next.js. v4.0 is a big upgrade with enough breaking changes to warrant a migration guide for existing users.
webdiscus
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
const target = { a: 1, b: 2 };
const handler = {
get(obj, prop) {
return prop in obj ? obj[prop] * 2 : 'Not found';
}
};
const proxy = new Proxy(target, handler);
// Add property to original object
target.c = 3;
// Modify existing property directly on proxy
proxy.a = 10;
// Use Reflect.get instead of direct property access
const result = Reflect.get(proxy, 'd', { custom: true });
console.log(proxy.a, proxy.b, proxy.c, result);
What is the output?
Anonymous Quiz
28%
10 4 6 Not found
29%
10 4 3 undefined
36%
20 4 6 Not found
7%
20 4 3 Not found
JavaScript (originally named LiveScript) turns thirty years old this year and the Deno team has put together a fantastic timeline-based tour of how much things have progressed from its first appearance in Netscape Navigator, through offshoots like JScript, standardization, and the introduction of Node.js, all the way through to the modern day.
The Deno Team
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
function analyze(...items) {
const [first, ...rest] = items;
const { length } = [...rest, 'bonus'];
const result = {
...first,
count: length,
};
console.log(result);
}
analyze({ id: 42, name: 'Item' }, 'a', 'b');
What is the output?
Anonymous Quiz
21%
{ id: 42, count: 3 }
36%
{ id: 42, name: 'Item', count: 2 }
38%
{ id: 42, name: 'Item', count: 3 }
4%
{ count: 3 }
CHALLENGE
const user = { id: 1, name: 'Alice' };
const userData = new WeakMap();
userData.set(user, { lastLogin: '2023-01-01' });
const clone = { ...user };
const originalData = userData.get(user);
const cloneData = userData.get(clone);
console.log(originalData, cloneData);
Two members of the Angular team presented a session at this week’s Google I/O event on the latest updates to the Angular framework in anticipation of the eventual release of Angular 20 next Thursday.
Chasanoff and Thompson (Google)
Please open Telegram to view this post
VIEW IN TELEGRAM
CHALLENGE
function mystery() {
try {
throw new Error('Oops');
return 'A';
} catch (err) {
return 'B';
} finally {
return 'C';
}
}
function wrapper() {
try {
return mystery();
} finally {
console.log('D');
}
}
console.log(wrapper());
CHALLENGE
function compose(...funcs) {
return function(x) {
return funcs.reduceRight((acc, fn) => fn(acc), x);
};
}
const add10 = x => x + 10;
const multiply2 = x => x * 2;
const toString = x => `Result: ${x}`;
const composed = compose(toString, multiply2, add10);
console.log(composed(5));
CHALLENGE
try {
try {
// Creating a custom error type
class CustomError extends Error {
constructor(message) {
super(message);
this.name = "CustomError";
}
}
const fn = () => {
throw new CustomError("Something went wrong");
};
try {
fn();
} catch (e) {
throw new TypeError("Type error occurred");
}
} catch (e) {
console.log(e instanceof Error, e.name, e instanceof TypeError);
}
} catch (e) {
console.log("Outer catch", e.message);
}
What is the output?
Anonymous Quiz
34%
true 'CustomError' false
32%
true 'TypeError' false
18%
false 'CustomError' false
17%
true 'TypeError' true
CHALLENGE
function* counter() {
let i = 1;
while (true) {
const reset = yield i++;
if (reset) {
i = 1;
}
}
}
const gen = counter();
console.log(gen.next().value);
console.log(gen.next().value);
console.log(gen.next(true).value);
console.log(gen.next().value);
What is the output?
Anonymous Quiz
30%
1, 2, 1, 2
36%
1, 2, undefined, 1
20%
1, 2, 1, 1
14%
1, 2, 3, 4