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
πŸ€” HelloCSV: A Drop-In, CSV Importing Workflow for JS Apps

If you or your users have CSV files to import, here’s a complete CSV importing workflow for the frontend that you can drop into your app. Basic docs.

HelloCSV
Please open Telegram to view this post
VIEW IN TELEGRAM
❀3πŸ”₯3πŸ‘2
CHALLENGE

const calculator = {
value: 10,
add: function(x) {
return this.value + x;
},
multiply: function(x) {
return this.value * x;
}
};

const add5 = calculator.add;
const double = calculator.multiply.bind(calculator);
const triple = calculator.multiply.bind({value: 3});

console.log(add5(2) + double(3) + triple(4));
❀2πŸ‘2
What is the output?
Anonymous Quiz
18%
44
41%
NaN
27%
42
15%
undefined2310
πŸ‘10❀4
🀟 Node 24 (Current) Released

Node’s release lines are shifting a little lately – v18 has gone EOL and now v23 gives way to v24 as the β€˜Current’ release for when you need the cutting edge features. It comes with npm 11, V8 13.6 (hello RegExp.escape, Float16Array, and `Error.isError`), the URLPattern API exposed by default, plus Undici 7.

Node.js Team
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ‘12❀1πŸ”₯1
CHALLENGE

const a = 9007199254740991n; // MAX_SAFE_INTEGER as BigInt
const b = 2n;
const c = a + b;

const result = [
a === 9007199254740991,
a + 1n === 9007199254740992n,
typeof c,
c > Number.MAX_SAFE_INTEGER,
BigInt(9007199254740992) - BigInt(9007199254740991)
];

console.log(result);
🀣4❀3πŸ‘2πŸ€”2
CHALLENGE

const team = {
name: 'Eagles',
players: ['Smith', 'Johnson', 'Williams'],
coach: { name: 'Brown', experience: 12 },
stats: { wins: 10, losses: 6 }
};

const {
name: teamName,
players: [firstPlayer, , thirdPlayer],
coach: { name },
stats: { wins, draws = 0 }
} = team;

console.log(`${teamName}-${firstPlayer}-${thirdPlayer}-${name}-${wins}-${draws}`);
πŸ‘5🀣5❀1
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣12πŸ‘5❀3
CHALLENGE

const user = {
name: "Alice",
age: 32,
role: "developer"
};

const handler = {
get(target, prop) {
return prop in target ?
`Value: ${target[prop]}` :
"Not found";
}
};

const proxy = new Proxy(user, handler);
delete user.age;

console.log(Reflect.get(proxy, "name") + ", " + proxy.age + ", " + proxy.skills);
πŸ‘4
πŸ˜†
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣34πŸ€”5πŸ‘4
CHALLENGE

const weakSet = new WeakSet();

let obj1 = { id: 1 };
let obj2 = { id: 2 };
let obj3 = obj1;

weakSet.add(obj1);
weakSet.add(obj2);

const results = [
weakSet.has(obj1),
weakSet.has(obj3),
weakSet.has({ id: 2 }),
weakSet.has(obj2)
];

obj1 = null;

console.log(results);
❀3πŸ‘1🀩1
❀11πŸ‘3πŸ”₯2πŸ€”1
Please open Telegram to view this post
VIEW IN TELEGRAM
🀣7πŸ‘6❀3πŸ”₯1🀩1
CHALLENGE

console.log(1);

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

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

console.log(7);
1πŸ‘2🀩1
πŸ‘6❀3πŸ”₯1
CHALLENGE

const user = { name: 'Alice' };
const ratings = new WeakMap();

ratings.set(user, 5);
const result = [];

result.push(ratings.has(user));
result.push(ratings.get(user));

// Create a reference-free object
let tempUser = { name: 'Bob' };
ratings.set(tempUser, 10);
result.push(ratings.has(tempUser));

// Remove the reference
tempUser = null;

// Try to iterate through WeakMap
result.push(typeof ratings[Symbol.iterator]);

console.log(result);
πŸ”₯5❀1
CHALLENGE

function processTransaction(amount) {
try {
if (typeof amount !== 'number') {
throw new TypeError('Amount must be a number');
}
if (amount <= 0) {
throw new RangeError('Amount must be positive');
}
return 'Transaction processed';
} catch (error) {
if (error instanceof TypeError) {
return { status: 'Type Error', message: error.message };
} else if (error instanceof RangeError) {
return { status: 'Range Error', message: error.message };
}
return { status: 'Unknown Error', message: error.message };
}
}

console.log(processTransaction(-50));
πŸ‘4🀩1