CHALLENGE
class Base {
value = 10;
getValue = () => this.value;
constructor() {
this.value = 20;
}
}
class Derived extends Base {
value = 30;
}
const d = new Derived();
console.log(d.getValue(), d.value);❤3🔥2
CHALLENGE
let order = [];
function a() {
try {
return 'try';
} finally {
order.push('a-finally');
return 'a-final-return';
}
}
function b() {
try {
throw new Error('x');
} catch (e) {
order.push('b-catch');
return 'b-catch-return';
} finally {
order.push('b-finally');
}
}
console.log(a(), b(), order.join(','));
❤1🔥1
CHALLENGE
const order = [];
order.push('start');
setTimeout(() => { order.push('timeout'); console.log(order.join(',')); }, 0);
Promise.resolve().then(() => order.push('promise1'));
async function foo() {
order.push('foo start');
await null;
order.push('foo end');
}
foo();
Promise.resolve().then(() => order.push('promise2'));
order.push('end');
❤2🔥1
CHALLENGE
const message = 'a😀bc';
const codePoints = [...message];
const combined = {
raw: message.length,
points: codePoints.length,
second: codePoints[1]
};
console.log(combined.raw, combined.points, combined.second);
❤1
❤2
CHALLENGE
class Counter {
#count = 0;
static #instances = 0;
constructor() { Counter.#instances++; }
#increment() { this.#count++; }
incrementAndGet() {
this.#increment();
return this.#count;
}
static get total() { return Counter.#instances; }
}
class SpecialCounter extends Counter {
incrementAndGet() {
return super.incrementAndGet() * 2;
}
}
const c1 = new Counter();
const c2 = new SpecialCounter();
console.log(`${c1.incrementAndGet()} ${c2.incrementAndGet()} ${Counter.total}`);🤣2
❤2
CHALLENGE
const arr = [1, 2, 3];
const log = [];
const result = arr.map((x, i) => {
if (i === 0) arr.push(4);
log.push(x);
return x * 2;
});
console.log(result.join(','), log.join(','), arr.join(','));
❤4🔥2👍1
What is the output?
Anonymous Quiz
36%
2,4,6,8 1,2,3,4 1,2,3,4
37%
2,4,6 1,2,3 1,2,3,4
16%
2,4,6,8 1,2,3 1,2,3,4
11%
2,4,6 1,2,3 1,2,3
A grab bag of performance lessons from a sprint that cut p75 'time-to-typeable' from 3.1s to 0.55s. Em dashes (the irony!) pushed V8 onto a slower regex path, a stray location.reload() caused half a million hidden reloads a day, and more.
Wang, Attard, and G (Anthropic)
Please open Telegram to view this post
VIEW IN TELEGRAM
❤2👍1
SolidJS's creator argues that HTMX, React, LiveView, and friends differ mostly in how they split the same three jobs (navigation, content, and instant UI feedback) between client and server. He then shows how Solid 2.0 aims to cover the whole spectrum.
Ryan Carniato
Please open Telegram to view this post
VIEW IN TELEGRAM
❤1