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
What is the output?
Anonymous Quiz
11%
8
27%
NaN
44%
16
18%
undefined
πŸ€”5πŸ”₯3❀2πŸ‘1
CHALLENGE

class EventEmitter {
constructor() {
this.events = new Map();
}

on(event, callback) {
if (!this.events.has(event)) {
this.events.set(event, []);
}
this.events.get(event).push(callback);
return this;
}

emit(event, ...args) {
const callbacks = this.events.get(event);
if (callbacks) {
callbacks.forEach(cb => cb(...args));
}
return this;
}
}

const emitter = new EventEmitter();
emitter.on('test', x => console.log(x * 2))
.on('test', x => console.log(x + 10))
.emit('test', 5);
❀6πŸ‘3
πŸ‘7❀1
CHALLENGE

const obj = {
data: ['x', 'y', 'z'],
*[Symbol.iterator]() {
for (let i = this.data.length - 1; i >= 0; i--) {
yield this.data[i].toUpperCase();
}
}
};

const result = [];
for (const item of obj) {
result.push(item);
if (result.length === 2) break;
}

console.log(result.join('-'));
❀13πŸ‘3πŸ”₯1
What is the output?
Anonymous Quiz
41%
Z-Y
27%
x-y
12%
z-y
20%
X-Y
πŸ‘1
CHALLENGE

const x = 15;
const y = 10;
const z = 3;

const result1 = x & y;
const result2 = x | y;
const result3 = x ^ y;
const result4 = ~x;
const result5 = y << z;
const result6 = y >> 1;

console.log(`${result1},${result2},${result3},${result4},${result5},${result6}`);
πŸ”₯4❀3πŸ‘2
❀2
πŸ‘€ Introducing LibPDF: PDF Parsing and Generation from TypeScript

LibPDF bills itself as β€˜the PDF library TypeScript deserves’ and supports parsing, modifying, signing and generating PDFs with a modern API in Node, Bun, and the browser. GitHub repo.

Documenso
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘11❀7πŸ”₯4
CHALLENGE

const wm = new WeakMap();
let obj1 = { name: 'John' };
let obj2 = { name: 'Jane' };

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

console.log(wm.get(obj1));
console.log(wm.has(obj2));

obj1 = null;
console.log(wm.get(obj1));

const normalObj = {};
try {
wm.set('string', 'value');
} catch (e) {
console.log('error');
}
πŸ‘6πŸ”₯2
πŸ€” Porting 100k Lines from TypeScript to Rust in a Month

A prolific JavaScript developer ported a PokΓ©mon battle simulator to Rust and shares his experiences and techniques used to work around issues where Claude Code would get bogged down in such a large task. He notes β€œLLM-based coding agents are such a great new tool” but require β€œengineering expertise and constant babysitting”.

Christopher Chedeau
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ‘5πŸ”₯4
CHALLENGE

console.log('start');

Promise.resolve().then(() => {
console.log('promise 1');
});

setTimeout(() => {
console.log('timeout');
}, 0);

Promise.resolve().then(() => {
console.log('promise 2');
}).then(() => {
console.log('promise 3');
});

console.log('end');
❀5πŸ‘3πŸ”₯3
πŸ™‚ OpenAI's Michael Bolin wrote a thorough technical review of how its OpenAI Codex agent works. Invaluable reading for anyone trying to implement their own coding agent or even if you just want to know how they do their thing.
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ”₯6πŸ‘5
CHALLENGE

const nums = [1, 2, 3];
const obj = { a: 1, b: 2 };
const newObj = { ...obj, b: 3, ...obj };

const arr1 = [4, 5];
const arr2 = [6, 7];
const combined = [...nums, ...arr1, ...arr2];

const [first, ...rest] = combined;
const { a, ...remaining } = newObj;

console.log(newObj.b);
console.log(rest.length);
console.log(remaining.b);
πŸ‘6πŸ”₯4❀1
What is the output?
Anonymous Quiz
19%
3 5 3
50%
2 6 2
25%
3 6 3
6%
2 5 2
πŸ”₯4πŸ‘3❀2πŸ€”2
🌲 Improving Single Executable Application Building in Node

First introduced two years ago, Node has a (still experimental) feature to build single executable applications that can be deployed to machines that don’t have Node installed. This week’s Node.js 25.5 release, with its --build-sea flag, moves the final injection step into Node itself, eliminating the need for external tooling and turning what was a multi-step, low-level process into a single command.

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

const user = {
profile: {
settings: {
theme: 'dark',
notifications: null
}
}
};

const getNotificationSound = (user) => {
return user?.profile?.settings?.notifications?.sound ?? 'default';
};

console.log(getNotificationSound(user));
console.log(getNotificationSound(null));
console.log(getNotificationSound({ profile: {} }));
❀6πŸ‘6πŸ”₯3
CHALLENGE

function processData() {
try {
console.log('start');
throw new Error('oops');
console.log('unreachable');
} catch (e) {
console.log('caught');
return 'error';
} finally {
console.log('cleanup');
}
console.log('end');
}

const result = processData();
console.log(result);
πŸ”₯9❀7πŸ‘4