JavaScript
32K subscribers
1.02K photos
9 videos
33 files
705 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

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

const result = processData();
console.log(result);
❀2πŸ‘2
Please open Telegram to view this post
VIEW IN TELEGRAM
❀8πŸ‘2πŸ”₯2
CHALLENGE

function highlight(strings, ...values) {
return strings.reduce((result, string, i) => {
const value = values[i] ? `<mark>${values[i]}</mark>` : '';
return result + string + value;
}, '');
}

const name = 'Sarah';
const age = 25;
const template = highlight`Hello ${name}, you are ${age} years old!`;
console.log(template);

const empty = highlight`No interpolation here`;
console.log(empty);
1❀8
CHALLENGE

class EventManager {
constructor() {
this.listeners = new Map();
}

addListener(event, callback) {
if (!this.listeners.has(event)) {
this.listeners.set(event, new Set());
}
this.listeners.get(event).add(callback);
}

removeListener(event, callback) {
this.listeners.get(event)?.delete(callback);
}
}

const manager = new EventManager();
const handler = () => console.log('handled');
manager.addListener('click', handler);
manager.removeListener('click', () => console.log('handled'));
console.log(manager.listeners.get('click').size);
❀4πŸ‘3πŸ”₯1
πŸ™‚ Mediabunny: A Complete Media Toolkit for JavaScript

Supporting both browsers and Node.js, this library lets you read, write and convert popular media file formats (e.g. MP4, MP3, and more) without needing to lean on dependencies like FFmpeg. You can make thumbnails, extract metadata, write code that gets converted into a video, and more. GitHub repo.

Vanilagy
Please open Telegram to view this post
VIEW IN TELEGRAM
1❀7πŸ”₯4πŸ‘3🀩1
CHALLENGE

const data = { a: 1, b: 2, c: 3 };
const { a, ...rest } = data;
const newObj = { ...rest, a, d: 4 };

const arr = [1, 2, 3, 4, 5];
const [first, , third, ...remaining] = arr;
const result = [...remaining, third, first];

console.log(newObj);
console.log(result);
😱 Google Chrome Turns 17: A History

A fantastic walkthrough of Chrome’s origins and its evolution over the years. Addy looks at key milestones (multi-process architecture for example), security, its steps into the world of AI, and more.

Addy Osmani
Please open Telegram to view this post
VIEW IN TELEGRAM
1❀6πŸ‘2πŸ”₯2🀩2
CHALLENGE

console.log('1');

setTimeout(() => console.log('2'), 0);

Promise.resolve().then(() => console.log('3'));

queueMicrotask(() => console.log('4'));

setTimeout(() => console.log('5'), 0);

Promise.resolve().then(() => {
console.log('6');
return Promise.resolve();
}).then(() => console.log('7'));

console.log('8');
❀6πŸ”₯3πŸ‘1
πŸ‘€ Peaks.js 4.0: UI Component for Interacting with Audio Waveforms

A project originally spawned from the BBC’s R&D department, Peaks renders audio waveforms to a canvas element and allows scrolling, zooming, and the sort of things you might otherwise see in an audio editor. LGPL licensed.

Chris Needham et al.
Please open Telegram to view this post
VIEW IN TELEGRAM
❀3πŸ‘2πŸ”₯2
CHALLENGE

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

try {
try {
throw new CustomError('inner error');
} catch (e) {
console.log(e.name);
throw new Error('outer error');
}
} catch (e) {
console.log(e.message);
console.log(e instanceof CustomError);
}
❀1
🎨 Eyecons is a VS Code icon theme that automatically adapts the color of icons to fit your editor's main theme – well, from this list anyway.
πŸ‘7❀1πŸ”₯1
CHALLENGE

const original = {
name: 'Sarah',
scores: [85, 92, 78],
details: {
age: 25,
city: 'Portland'
}
};

const copy1 = { ...original };
const copy2 = JSON.parse(JSON.stringify(original));

copy1.name = 'Emma';
copy1.scores.push(95);
copy1.details.age = 30;

console.log(original.name, original.scores.length, original.details.age);
πŸ”₯4❀3πŸ‘1
❀4πŸ‘1
😭 A Major Supply Chain Attack Hits the npm Ecosystem

In July, Socket warned us about a phishing campaign targeting npm package publishers. Sadly, a prolific package author (among others, like DuckDB, who explain how the attack worked on them) fell victim to the scam, resulting in some popular packages becoming compromised (like Chalk, debug, and others).

Gooding, Brown, et al. (Socket)
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1πŸ”₯1πŸ€”1