CHALLENGE
function Animal(name) {
this.name = name;
}
Animal.prototype.speak = function () {
return `${this.name} makes a sound`;
};
function Dog(name) {
Animal.call(this, name);
}
Dog.prototype = Object.create(Animal.prototype);
Dog.prototype.constructor = Dog;
Dog.prototype.speak = function () {
return `${Animal.prototype.speak.call(this)} (bark)`;
};
const d = new Dog('Rex');
console.log(
d.speak(),
d instanceof Animal,
d.constructor === Dog,
Object.getPrototypeOf(d) === Dog.prototype
);
export {};❤1👍1🔥1
CHALLENGE
class Base {
static count = 0;
static #secret;
static {
Base.#secret = 10;
Base.count += 1;
}
static getSecret() {
return Base.#secret;
}
}
class Derived extends Base {
static {
Base.count += 100;
}
}
console.log(Base.count, Derived.count, Base.getSecret());❤1🔥1
👍2🔥1
A practical guide to publishing npm packages more safely in 2026, written by someone who's released several popular packages (like postcss and nanoid). As well as showing how to use things like staged publishing and trusted publishing, he explains why and the security benefits of doing so.
Andrey Sitnik
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6🔥2
CHALLENGE
function* inner() {
yield 1;
yield 2;
return 10;
}
function* outer() {
const result = yield* inner();
yield result;
yield 3;
}
const gen = outer();
const a = gen.next().value;
const b = gen.next().value;
const c = gen.next().value;
const d = gen.next().value;
console.log(a, b, c, d);What is the output?
Anonymous Quiz
26%
1 2 3 10
36%
1 2 undefined 3
21%
1 2 10 undefined
17%
1 2 10 3
❤2
A new entry into the growing field of JS/TS native ahead-of-time compilers that makes the promise that "what compiles behaves byte-for-byte like Node." Static by default, but you can opt in to a --dynamic mode which embeds a JavaScript engine for runtime dynamism. GitHub repo.
Vercel Labs
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4👍1🔥1
CHALLENGE
function tag(strings, ...values) {
// strings.raw preserves literal escape sequences
const rawParts = strings.raw;
let result = rawParts.join('|');
result += '::' + values.join(',');
return result;
}
const x = 5;
const output = tag`Line1\nLine2${x}End`;
console.log(output);❤4👍4🔥1
What is the output?
Anonymous Quiz
31%
Line1\nLine2|End::5
42%
Line1\nLine2,End::5
20%
Line1nLine2|End::5
7%
5::Line1\nLine2|End
🔥4
CHALLENGE
const config = { retries: 0, timeout: null, name: '' };
const a = config.retries || 5;
const b = config.timeout ?? 10;
const c = config.name || 'default';
const d = config.missing?.value ?? 'fallback';
let calls = 0;
const sideEffect = () => { calls++; return true; };
const e = config.retries && sideEffect();
console.log(a, b, c, d, e, calls);❤4👍2🔥2
What is the output?
Anonymous Quiz
34%
5 10 default fallback 0 0
30%
0 10 default fallback 0 0
24%
5 10 default fallback 1 1
12%
5 null default fallback 0 0
❤3🔥1
CHALLENGE
function tag(strings, ...values) {
return strings.raw.join('|') + '=' + values.reduce((sum, v) => sum + v, 0);
}
const x = 5;
const y = 10;
console.log(tag`Sum\n${x}and${y}end`);❤4👍1
What is the output?
Anonymous Quiz
37%
Sum\n|and|end=15
36%
Sum\n|and|end=105
18%
Sum|and|end=15
10%
Sum\n,and,end=15
🔥4❤3👍2
CHALLENGE
const order = [];
const log = (s) => order.push(s);
log('start');
Promise.resolve().then(() => {
log('p1');
return Promise.resolve();
}).then(() => log('p1-2'));
async function foo() {
log('foo-start');
await null;
log('foo-end');
}
foo();
Promise.resolve().then(() => log('p2'));
log('end');
setTimeout(() => console.log(order.join(' ')), 0);
❤4🔥1
CHALLENGE
const a = [] + {};
const b = {} + [];
const c = 1 + '1' - 1;
const d = '5' + 3 - 2;
const e = true + true;
console.log(a, b, c, d, e);👍5🤣3❤2🔥1
What is the output?
Anonymous Quiz
11%
0 0 10 51 2
28%
[object Object] [object Object] 10 51 1
53%
[object Object] [object Object] 10 51 2
9%
[object Object] 0 10 51 2
❤5👍3
CHALLENGE
let arr = [];
for (let i = 0; i < 3; i++) {
if (i === 1) {
let i = 10;
arr.push(i);
continue;
}
arr.push(i);
}
console.log(arr.join('-'));
❤4🔥4👍2
❤5🤔3