JavaScript
32K subscribers
1.04K photos
10 videos
33 files
719 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

console.log('1');

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

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

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

console.log('6');
❀5πŸ‘4
🀟 A Year of Improving Node.js Compatibility in Cloudflare Workers

β€œWe’ve been busy,” says Cloudflare which recently announced it’s bringing Node.js HTTP server support to its Workers function platform. This post goes deep into the technicalities, covering what areas of the standard library is supported, how the file system works (Workers doesn’t have a typical file system), how input/output streams work, and more. And you can use all of this now.

James M Snell (Cloudflare)
Please open Telegram to view this post
VIEW IN TELEGRAM
❀7πŸ”₯3πŸ‘1
CHALLENGE

function processData() {
try {
console.log('processing');
return 'success';
} catch (error) {
console.log('error caught');
return 'failed';
} finally {
console.log('cleanup');
}
}

const result = processData();
console.log('result:', result);
πŸ”₯1
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣11❀4πŸ‘1
CHALLENGE

class EventEmitter {
constructor() { this.events = {}; }
on(event, fn) { (this.events[event] ||= []).push(fn); }
emit(event, data) { this.events[event]?.forEach(fn => fn(data)); }
}

class Logger {
log(msg) { console.log(`LOG: ${msg}`); }
}

class Counter {
constructor() { this.count = 0; }
increment() { this.count++; console.log(this.count); }
}

function withLogging(target) {
const logger = new Logger();
return new Proxy(target, {
get(obj, prop) {
if (typeof obj[prop] === 'function') {
return function(...args) {
logger.log(`calling ${prop}`);
return obj[prop].apply(obj, args);
};
}
return obj[prop];
}
});
}

const emitter = withLogging(new EventEmitter());
const counter = new Counter();
emitter.on('tick', () => counter.increment());
emitter.emit('tick');
emitter.emit('tick');
πŸ€”5
CHALLENGE

class Animal {
constructor(name) {
this.name = name;
}
speak() {
return `${this.name} makes a sound`;
}
}

class Dog extends Animal {
speak() {
return super.speak() + ' and barks';
}
}

const pet = new Dog('Rex');
console.log(pet.speak());
console.log(pet instanceof Animal);
console.log(pet.constructor.name);
❀3
✌️ The State of JavaScript 2025 Survey

Each year, Devographics runs an epic survey of as many JavaScript community members as it can and turns the results into an interesting report on the state of the ecosystem – here’s the results from 2024. If you have the time, fill it in, especially as they format it in a way where you can actually learn about stuff as you go.

Devographics
Please open Telegram to view this post
VIEW IN TELEGRAM
❀2πŸ€”2πŸ”₯1
CHALLENGE

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

transform(fn) {
return new DataProcessor(fn(this.value));
}

getValue() {
return this.value;
}
}

const multiply = x => x * 2;
const add = x => x + 10;
const square = x => x * x;

const result = new DataProcessor(5)
.transform(multiply)
.transform(add)
.transform(square)
.getValue();

console.log(result);
❀1
What is the output?
Anonymous Quiz
21%
300
25%
100
48%
400
6%
625
❀7πŸ‘3πŸ”₯1
CHALLENGE

const Flyable = {
fly() { return 'flying'; }
};

const Swimmable = {
swim() { return 'swimming'; }
};

function mixin(Base, ...mixins) {
mixins.forEach(mixin => Object.assign(Base.prototype, mixin));
return Base;
}

class Bird {}
class Fish {}

const FlyingFish = mixin(class extends Fish {}, Flyable, Swimmable);
const instance = new FlyingFish();
console.log(instance.swim());
console.log(instance.fly());
console.log(instance instanceof Fish);
CHALLENGE

function createCounter() {
let count = 0;
return function(increment = 1) {
count += increment;
return count;
};
}

const counter1 = createCounter();
const counter2 = createCounter();

console.log(counter1());
console.log(counter1(5));
console.log(counter2(3));
console.log(counter1());
console.log(counter2());
❀9πŸ€”5
CHALLENGE

const arr = [1, 2, 3, 4, 5];
const obj = { a: 1, b: 2, c: 3 };

const result1 = Object.keys(obj).length;
const result2 = arr.length;

delete obj.b;
obj.d = 4;

const result3 = Object.keys(obj).length;
const result4 = arr.push(6);

arr.length = 3;

const result5 = arr.length;
const result6 = Object.keys(obj).join('');

console.log(result1, result2, result3, result4, result5, result6);
❀6πŸ‘1πŸ”₯1
πŸ’» How Deno Protects Against npm Exploits

The maintainers of the Deno runtime reflect on the recent npm ecosystem security issues and show off how Deno’s non-permissive explicit β€˜secure by default’ model can help.

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