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
πŸ™‚ 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
❀6πŸ€”3πŸ‘2πŸ”₯1
CHALLENGE

const target = { name: 'Sarah', age: 25 };

const handler = {
get(obj, prop) {
if (prop === 'toString') {
return () => `Person: ${obj.name}`;
}
return Reflect.get(obj, prop);
},
set(obj, prop, value) {
if (prop === 'age' && value < 0) {
return false;
}
return Reflect.set(obj, prop, value);
}
};

const proxy = new Proxy(target, handler);
proxy.age = -5;
proxy.location = 'NYC';
console.log(proxy.toString());
console.log(proxy.age);
console.log(proxy.location);
❀9πŸ‘6πŸ”₯2
πŸ‘4❀1πŸ”₯1
CHALLENGE

const obj = {
name: 'Sarah',
greet() {
console.log(`Hello, ${this.name}`);
}
};

const person = { name: 'Mike' };
const func = obj.greet;

obj.greet();
func();
func.call(person);
person.hello = obj.greet;
person.hello();
πŸ”₯7πŸ‘5❀3
CHALLENGE

const source = { a: 1, b: { c: 2 } };
const target1 = Object.assign({}, source);
const target2 = { ...source };

source.b.c = 99;
target1.a = 10;
target2.b.c = 50;

console.log(source.a);
console.log(source.b.c);
console.log(target1.a);
console.log(target1.b.c);
console.log(target2.a);
console.log(target2.b.c);
❀5πŸ‘4πŸ”₯3
❀5πŸ‘3πŸ”₯2
✌️ Four Heavyweights Drop Updates

Four stalwarts of the JavaScript ecosystem all shipped notable releases this week, and odds are you're using at least one of them:

β€’ Gatsby v5.16 proves Gatsby, once considered neck-and-neck with Next.js in the React world, is not 'dead'. The headline feature is React 19 support.

β€’ Babel 7 just shipped its final release. "After years in the making, Babel 8 is finally ready," in release candidate form, at least.

β€’ Rspress 2.0 is a major release for the high-performance Rust-powered, but JavaScript-facing, static site generator.

β€’ Lodash 4.17.23 sounds minor, but it's a 'security reset' for the still heavily used utility library and is designed to provide a base for a longer future.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ”₯9πŸ‘5❀4
CHALLENGE

const memoize = (fn) => {
const cache = new Map();
return (...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(10));
console.log(fibonacci(5));
console.log(fibonacci(10));
πŸ”₯8❀4πŸ‘2
What is the output?
Anonymous Quiz
28%
89 5 89
41%
55 5 55
16%
55 5 21
15%
55 8 55
❀2πŸ”₯2πŸ‘1
⁉️ How Not to Parse Numbers in JavaScript

Why use a proper locale-aware API to parse numbers when you can hand-roll a maze of string splits, separator swaps, and implicit type coercions that silently break on edge cases?

Remy Porter (The Daily WTF)
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ”₯6πŸ‘3
CHALLENGE

let counter = 0;

const increment = () => ++counter;
const getValue = () => counter;

const obj = {
get value() {
increment();
return getValue();
}
};

console.log(obj.value);
console.log(obj.value);
console.log(counter);
❀8πŸ”₯5πŸ‘2
What is the output?
Anonymous Quiz
23%
1 1 1
23%
2 4 4
18%
0 1 2
35%
1 2 2
❀2πŸ‘2πŸ”₯1