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
CHALLENGE

const operations = {
value: 10,
multiply: function(x) {
return this.value * x;
},
arrow: (x) => {
return this.value * x;
},
nested: function() {
const inner = () => this.value * 2;
return inner();
}
};

console.log(operations.multiply(3));
console.log(operations.arrow(3));
console.log(operations.nested());
๐Ÿ‘6๐Ÿ”ฅ4
โค2๐Ÿ”ฅ2
๐Ÿคฉ broz (above) is a simple Node/Electron tool you can use via npx if you're tired of fidgeting around to get a screenshot of a site with a clean look. From the maintainer of Shiki.
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ”ฅ6โค5๐Ÿ‘3
CHALLENGE

class Calculator {
constructor(value) {
this.value = value;
}

add(num) {
this.value += num;
return this;
}

getValue = () => this.value;
}

const calc = new Calculator(10);
const addMethod = calc.add;
const getValueMethod = calc.getValue;

addMethod.call({value: 5}, 3);
console.log(calc.getValue());
console.log(getValueMethod());
โค5๐Ÿ‘2๐Ÿ”ฅ2๐Ÿคฉ2
What is the output?
Anonymous Quiz
21%
10 8
45%
10 10
27%
8 10
8%
13 13
๐Ÿ‘3โค2
๐Ÿ˜ฎ npmx: A New npm Registry Package Browser

A smooth, fast way to browse packages on the official npm registry. Itโ€™s certainly fast, smooth, and you see more info up front and center - check out the axios page for example. โ€œWeโ€™re not replacing the npm registry, but instead providing an elevated developer experience through a fast, modern UI.โ€

npmx
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ”ฅ5โค2๐Ÿ‘2๐Ÿคฃ1
CHALLENGE

const wm = new WeakMap();
const obj1 = { name: 'Sarah' };
const obj2 = { name: 'Mike' };

wm.set(obj1, 'developer');
wm.set(obj2, 'designer');

console.log(wm.get(obj1));
console.log(wm.has(obj2));
console.log(wm.get({ name: 'Sarah' }));
console.log(wm.delete(obj1));
console.log(wm.has(obj1));
โค4๐Ÿ”ฅ2๐Ÿ‘1
โœŒ๏ธ 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