JavaScript
31.9K subscribers
1.01K photos
9 videos
33 files
693 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 user = {
name: 'Alice',
age: 30
};

const handler = {
get(target, prop) {
if (prop in target) {
return target[prop];
}
return `Property '${prop}' doesn't exist`;
},
set(target, prop, value) {
if (prop === 'age' && typeof value !== 'number') {
console.log('Age must be a number');
return false;
}
target[prop] = value;
return true;
}
};

const proxy = new Proxy(user, handler);
proxy.age = '32';
proxy.age = 32;
console.log(proxy.job);
πŸ‘7❀3
πŸ˜†
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣45πŸ‘12❀2πŸ”₯1πŸ€”1
CHALLENGE

function executePromises() {
console.log(1);

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

Promise.resolve().then(() => {
console.log(3);
setTimeout(() => {
console.log(4);
}, 0);
}).then(() => {
console.log(5);
});

console.log(6);
}

executePromises();
πŸ”₯3❀2πŸ‘1
πŸ‘6🀩5❀2πŸ”₯1
✌️ The ECMAScript Records and Tuples Proposal Has Been Withdrawn

Several years in the making, the record and tuples proposal offered two new deeply immutable data structures to JavaScript, but at this week’s TC39 meeting, the consensus was to drop it.
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘7πŸ€”4🀣3❀2πŸ”₯1
CHALLENGE

function main() {
console.log(1);

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

Promise.resolve().then(() => {
console.log(3);
setTimeout(() => console.log(4), 0);
}).then(() => console.log(5));

Promise.resolve().then(() => console.log(6));

console.log(7);
}

main();
❀5πŸ‘2
πŸ‘6πŸ”₯3❀2
πŸ‘ A Flowing WebGL Gradient, Deconstructed

Even if you don’t want to render a neat plasma-style effect on the Web, this is a wonderfully deep exploration of the math and technology behind doing so using simple GLSL code that could be easily understood by any JavaScript developer.

Alex Harri
Please open Telegram to view this post
VIEW IN TELEGRAM
❀3πŸ‘2🀣2
CHALLENGE

const team = {
members: ['Alice', 'Bob', 'Charlie'],
[Symbol.iterator]: function*() {
let index = 0;
while(index < this.members.length) {
yield this.members[index++].toUpperCase();
}
}
};

const result = [];
for (const member of team) {
result.push(member);
}

console.log(result.join('-'));
πŸ‘4
πŸ‘9❀2πŸ”₯2
Please open Telegram to view this post
VIEW IN TELEGRAM
1❀10πŸ‘2πŸ”₯2
CHALLENGE

const user = {
profile: {
name: 'Alice',
settings: {
notifications: {
email: true,
sms: false
}
}
},
getPreference(type) {
return this.profile?.settings?.notifications?.[type] ?? 'not configured';
}
};

const admin = {
profile: {
name: 'Admin',
settings: null
},
getPreference: user.getPreference
};

console.log(admin.getPreference('email'));
πŸ‘4❀2
πŸ€”10πŸ‘9❀1
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘6❀5πŸ”₯2
CHALLENGE

const companies = [
{ name: 'TechCorp', founded: 2010 },
{ name: 'DataSystems', founded: 2015 },
{ name: 'WebSolutions', founded: 2008 }
];

const activeClients = new WeakSet();

activeClients.add(companies[0]);
activeClients.add(companies[2]);

companies.pop();

const result = [
activeClients.has(companies[0]),
activeClients.has(companies[1]),
typeof activeClients.size
];

console.log(result);
❀4πŸ‘1πŸ€”1
✌️ Love/Hate: Upgrading to Web2.5 with Local-First

Kyle Simpson - dotJS 2025
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘3❀2πŸ€”2
CHALLENGE

function processConfig(config) {
const defaults = {
timeout: 1000,
retries: 3,
enabled: false,
count: 0
};

const settings = {
...defaults,
...config
};

const effectiveTimeout = settings.timeout ?? 500;
const effectiveRetries = settings.retries ?? 1;
const effectiveEnabled = settings.enabled ?? true;
const effectiveCount = settings.count ?? 5;

console.log([effectiveTimeout, effectiveRetries, effectiveEnabled, effectiveCount]);
}

processConfig({ timeout: null, retries: 0, enabled: undefined });
πŸ‘5πŸ€”1
πŸ”₯7❀5πŸ‘1πŸ€”1