JavaScript
31K subscribers
1.23K photos
10 videos
33 files
904 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
🖼️ JPEG XL: The modern image format is now supported by all major browsers, with Firefox 158 the latest to enable it by default. Jake Archibald pits it against AVIF in this extensive review. What I find amazing is what it's able to render in under 100 bytes.
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3❤2🤣2🔥1
CHALLENGE

const base = { greet() { return 'hi'; } };
const obj = Object.create(base, {
x: { value: 1, enumerable: true },
y: { value: 2, enumerable: false }
});
const spread = { ...obj };
const assigned = Object.assign({}, obj);
console.log(
spread.x,
spread.y,
spread.greet,
assigned.y,
Object.keys(spread).length
);
CHALLENGE

const wm = new WeakMap();
class Counter {
#id;
static #nextId = 0;
constructor() {
this.#id = Counter.#nextId++;
wm.set(this, { count: 0, id: this.#id });
}
inc() {
const data = wm.get(this);
data.count++;
return data.count;
}
}
const a = new Counter();
const b = new Counter();
a.inc(); a.inc();
b.inc();
console.log(`${a.inc()} ${b.inc()} ${wm.has(a)} ${wm.get(a).id} ${wm.get(b).id}`);