JavaScript
31.1K subscribers
1.23K photos
10 videos
33 files
898 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript ๐Ÿš€ Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
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');
โค3๐Ÿ”ฅ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);
โค3
โค4
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}`);
๐Ÿคฃ3
What is the output?
Anonymous Quiz
20%
1 2 1
38%
1 4 2
27%
2 2 2
14%
1 2 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
๐Ÿ˜ฎ How Anthropic Made Claude's Apps 3x Faster in Two Weeks

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
โค3๐Ÿ‘3
๐Ÿคฉ The Grand Unifying Architecture of Frontend

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
๐Ÿ‘3โค2
CHALLENGE

const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const pipe = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));

const add1 = x => x + 1;
const double = x => x * 2;
const square = x => x * x;

const composed = compose(square, double, add1);
const piped = pipe(square, double, add1);

console.log(composed(3), piped(3));
โค2
What is the output?
Anonymous Quiz
26%
49 25
34%
19 64
33%
64 19
7%
81 9
๐Ÿ‘€ Size Limit: A JavaScript Performance Budgeting Tool

Set a size or load-time budget for your code and this tool can fail CI (or flag a PR) if a change goes over it. You can also do one-off checks and see visualizations of where the bytes are. Framework-agnostic and doesnโ€™t care which bundler or CI you use.

Andrey Sitnik
Please open Telegram to view this post
VIEW IN TELEGRAM
โค1