JavaScript
33K subscribers
1.14K photos
10 videos
33 files
814 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
✌️ It’s About to Get a Lot Easier For Your JavaScript to Clean Up After Itself

A fun technical exploration of Symbol.dispose and using, two new features that’ll ease many headaches around cleaning up after yourself: closing connections, freeing resources, etc. Just watch out for the Muppets…

Mat Marquis
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘5πŸ”₯2
CHALLENGE

const cache = new Map();

function memoize(fn) {
return function(...args) {
const key = JSON.stringify(args);
if (cache.has(key)) {
return cache.get(key);
}
const result = fn(...args);
cache.set(key, result);
return result;
};
}

const fibonacci = memoize((n) => {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
});

console.log(fibonacci(5));
console.log(cache.size);
❀9πŸ”₯2πŸ‘1
What is the output?
Anonymous Quiz
29%
5 5
42%
5 6
22%
8 6
7%
8 5
❀5πŸ”₯3πŸ‘2
⭐ Shades of Halftone is Maxime Heckel's grand tour of pixelation, dithering, and the creation of GLSL-powered halftone effects with React Three Fiber. An aesthetic increasingly popular in modern web design and digital art.
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘5πŸ”₯2
This is how the new generation learns about the Node.js EventLoop πŸ˜‚
Please open Telegram to view this post
VIEW IN TELEGRAM
❀11πŸ‘6🀣4πŸ”₯3
CHALLENGE

class CustomError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
}
}

try {
throw new CustomError("Something went wrong");
} catch (error) {
console.log(error.name);
console.log(error instanceof Error);
console.log(error instanceof CustomError);
console.log(typeof error.stack);
}
❀8πŸ‘6πŸ”₯6
😬 Heroku, the cloud hosting/PaaS pioneer, has adopted a 'sustaining engineering model', with no new features in the pipeline. The dev community heard the 'death rattle' and migrate off heroku has joined many to-do lists.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘6πŸ”₯4❀3
CHALLENGE

function createUser(name = 'Guest', age = 0, active = true) {
return { name, age, active };
}

const users = [
createUser('Sarah', 25),
createUser('Mike'),
createUser('Emma', undefined, false),
createUser(null, 30)
];

console.log(users.map(u => `${u.name}-${u.age}-${u.active}`).join('|'));
❀3πŸ‘2
🀟 Halving Node.js Memory Usage with Pointer Compression

Does 50% memory savings in production sound good? Cloudflare, Igalia, and the Node project have collaborated on node-caged, a Docker image containing Node 25 with V8 pointer compression enabled. Matteo digs into all the details here – this is neat work, though there are tradeoffs to consider.

Matteo Collina
Please open Telegram to view this post
VIEW IN TELEGRAM
❀9πŸ”₯5πŸ‘4🀩1
It's true πŸ˜‚ her pornhub page
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣31πŸ”₯7πŸ‘6❀1
CHALLENGE

const user = {
name: 'Sarah',
age: 25,
greet() {
return `Hello, I'm ${this.name}`;
}
};

const keys = Object.keys(user);
const values = Object.values(user);
const entries = Object.entries(user);

console.log(keys.length);
console.log(values.includes('Sarah'));
console.log(entries[2][0]);
πŸ”₯6❀4πŸ‘2
❀6πŸ”₯2
CHALLENGE

const user = {
name: 'Sarah',
profile: {
settings: {
theme: 'dark'
}
}
};

const config = {
name: 'John',
profile: null
};

console.log(user.profile?.settings?.theme);
console.log(config.profile?.settings?.theme);
console.log(user.profile?.preferences?.language);
console.log(config.profile?.settings?.theme ?? 'light');
πŸ‘5πŸ”₯3❀1
CHALLENGE

function testScope() {
var x = 'outer';
let y = 'outer';

if (true) {
var x = 'inner';
let y = 'inner';
console.log(x, y);
}

console.log(x, y);
}

testScope();
πŸ‘5❀4πŸ”₯2🀣2
✌️ Oxfmt Beta: A Fast, Rust-Powered JavaScript Code Formatter

A 100% Prettier-compatible JavaScript code formatter (and sister project of Oxlint) that boasts being 30x faster than Prettier and 3x faster than Biome. Since the alpha, it now supports embedded language formatting (JSX, YAML, HTML, etc), Tailwind CSS class sorting, import sorting, and more.

Boshen, Dunqing, and Sugiura (VoidZero)
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘6❀1πŸ”₯1