JavaScript
31.1K subscribers
1.22K photos
10 videos
33 files
894 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

class Timer {
#ticks = 0;
tick = () => {
this.#ticks++;
return this.#ticks;
};
reset() {
this.#ticks = 0;
return this.#ticks;
}
}

const t = new Timer();
const { tick, reset } = t;
let result;
try {
result = reset();
} catch (e) {
result = e.constructor.name;
}
console.log(tick(), tick(), result);
2👍2
1🤔1
👀 htmx 4.0 has landed, the first major release in two years, with lots of changes. It remains a neat way to add interactivity to server-rendered pages without reaching for a frontend framework.
Please open Telegram to view this post
VIEW IN TELEGRAM
3
CHALLENGE

function createCounters() {
const counters = [];
for (let i = 0; i < 3; i++) {
let count = 0;
counters.push(() => {
count += i;
return count;
});
}
return counters;
}

const counters = createCounters();
const first = counters.map(fn => fn()).join(',');
const second = counters.map(fn => fn()).join(',');
console.log(first, second);
2🔥1
👍1
🔥 The Depths of JavaScript: Minesweeper in 247 Bytes

An analysis of a playable 8x8 Minesweeper implementation in one line of JavaScript, complete with flags and cascading blank cells. The author's 658-byte version is impressive enough, but this post covers the tricks to make it 62% smaller than that!

yui and DNEK
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥72
👀 Uppy 6.0: A Modular JavaScript File Uploader

Resumable uploads from disk, Dropbox or GDrive, with wrappers for React, Vue, Svelte & Angular. This version focuses on clean-up, with a rewritten S3 plugin and fewer packages to manage.

Transloadit
Please open Telegram to view this post
VIEW IN TELEGRAM
🤔31👍1🔥1
🌲 A Recap of Node.js Interactive 2026

Node.js Interactive returned for the first time since 2019 as part of this month's RenderATL event with Node contributors and invited speakers tackling Node's near-term roadmap in areas like AI, supply chain security, WinterCG becoming Ecma TC55, work on QUIC and HTTP/3 support, and Node's move to one major release a year.

Aviv Keller
Please open Telegram to view this post
VIEW IN TELEGRAM
3👍1🔥1
CHALLENGE

class Base {
#value = 0;
get value() { return this.#value; }
set value(v) { this.#value = v * 2; }
}
class Derived extends Base {
get value() { return super.value + 1; }
set value(v) { super.value = v + 10; }
}
const d = new Derived();
d.value = 5;
console.log(d.value, d.value = 100, d.value);
CHALLENGE

const base = {
get value() {
return this._value ?? 'default';
},
set value(v) {
this._value = v;
}
};

const derived = Object.create(base);
derived.value = 'hello';

const another = Object.create(base);

console.log(derived.value, another.value, derived.hasOwnProperty('_value'));
🤣7
CHALLENGE

function Timer() {
this.seconds = 0;
this.tick = () => { this.seconds++; };
this.tickRegular = function () { this.seconds++; };
}

const t = new Timer();
const { tick, tickRegular } = t;
tick();

let regularResult;
try {
tickRegular();
regularResult = 'no error';
} catch (e) {
regularResult = e instanceof TypeError;
}

console.log(t.seconds, regularResult);
4👍1
What is the output?
Anonymous Quiz
19%
1 false
45%
1 true
24%
0 true
12%
NaN true
🔥5
CHALLENGE

const a = [] + [];
const b = [] + {};
const c = {} + [];
const d = 1 + "1" - 1;
console.log(a, b, c, d);
🔥2🤔2🤩1
CHALLENGE

let count = 0;
const inc = () => (count += 1, count);
const a = 0 || inc();
const b = null ?? inc();
const c = a && inc();
const d = b?.toString() || inc();
console.log(a, b, c, d, count);
3👍2
👍4🔥3
CHALLENGE

const nums = [1, 2, 3, 4, 5];
const result = nums
.filter(n => n % 2 !== 0)
.map(n => n ** 2)
.reduce((acc, n) => acc + n, 0);

const arr = [10, , 20, undefined, 30];
const mapped = arr.map(x => x * 2);

console.log(result, mapped);
2🔥2
CHALLENGE

let i = 0;
const key = () => `k${i++}`;
const obj = {
[key()]: i,
[key()]: i,
[key()]: i,
};
console.log(Object.keys(obj).join(','), obj.k0, obj.k1, obj.k2);
3