CHALLENGE
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
Promise.resolve().then(() => {
console.log('5');
setTimeout(() => console.log('6'), 0);
});
console.log('7');โค1๐1๐ฅ1
What is the output?
Anonymous Quiz
17%
1 4 7 5 3 6 2
28%
1 7 4 3 5 2 6
37%
1 4 7 3 5 2 6
18%
1 4 7 2 3 5 6
โค12๐คฃ3
TypeScript 6.0 is now in beta. It's a "clean up your tsconfig" release, not meant to wow but to make sense as a bridge to the eventual Go-powered 'native' TypeScript 7 compiler.
Please open Telegram to view this post
VIEW IN TELEGRAM
โค5๐4๐ฅ3
Transformers.js brings Hugging Faceโs transformer models directly to the JavaScript world, meaning you can run numerous NLP, vision, and audio models right from Node.js. v4 is WebGPU powered and is now installable with npm.
Hugging Face
Please open Telegram to view this post
VIEW IN TELEGRAM
๐5๐ฅ5โค2
CHALLENGE
const operations = {
value: 10,
multiply: function(x) {
return this.value * x;
},
arrow: (x) => {
return this.value * x;
},
nested: function() {
const inner = () => this.value * 2;
return inner();
}
};
console.log(operations.multiply(3));
console.log(operations.arrow(3));
console.log(operations.nested());๐6๐ฅ4
โค2๐ฅ2
CHALLENGE
class Calculator {
constructor(value) {
this.value = value;
}
add(num) {
this.value += num;
return this;
}
getValue = () => this.value;
}
const calc = new Calculator(10);
const addMethod = calc.add;
const getValueMethod = calc.getValue;
addMethod.call({value: 5}, 3);
console.log(calc.getValue());
console.log(getValueMethod());โค5๐2๐ฅ2๐คฉ2
๐3โค2
A smooth, fast way to browse packages on the official npm registry. Itโs certainly fast, smooth, and you see more info up front and center - check out the axios page for example. โWeโre not replacing the npm registry, but instead providing an elevated developer experience through a fast, modern UI.โ
npmx
Please open Telegram to view this post
VIEW IN TELEGRAM
๐ฅ5โค2๐2๐คฃ1
CHALLENGE
const wm = new WeakMap();
const obj1 = { name: 'Sarah' };
const obj2 = { name: 'Mike' };
wm.set(obj1, 'developer');
wm.set(obj2, 'designer');
console.log(wm.get(obj1));
console.log(wm.has(obj2));
console.log(wm.get({ name: 'Sarah' }));
console.log(wm.delete(obj1));
console.log(wm.has(obj1));
โค4๐ฅ2๐1
A fun technical exploration of Symbol.dispose and using, two new features thatโll ease many headaches around cleaning up after yourself: closing connections, freeing resources, etc. Just watch out for the Muppetsโฆ
Mat Marquis
Please open Telegram to view this post
VIEW IN TELEGRAM
โค5๐5๐ฅ2
CHALLENGE
const cache = new Map();
function memoize(fn) {
return function(...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(5));
console.log(cache.size);
โค9๐ฅ2๐1
โค5๐ฅ3๐2
Please open Telegram to view this post
VIEW IN TELEGRAM
โค5๐5๐ฅ2
This is how the new generation learns about the Node.js EventLoop ๐
Please open Telegram to view this post
VIEW IN TELEGRAM
โค11๐6๐คฃ4๐ฅ3
CHALLENGE
class CustomError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
}
}
try {
throw new CustomError("Something went wrong");
} catch (error) {
console.log(error.name);
console.log(error instanceof Error);
console.log(error instanceof CustomError);
console.log(typeof error.stack);
}โค8๐6๐ฅ6
What is the output?
Anonymous Quiz
37%
CustomError true true string
40%
CustomError true true undefined
16%
Error true false string
7%
CustomError false true undefined
Please open Telegram to view this post
VIEW IN TELEGRAM
๐6๐ฅ4โค3
CHALLENGE
function createUser(name = 'Guest', age = 0, active = true) {
return { name, age, active };
}
const users = [
createUser('Sarah', 25),
createUser('Mike'),
createUser('Emma', undefined, false),
createUser(null, 30)
];
console.log(users.map(u => `${u.name}-${u.age}-${u.active}`).join('|'));โค3๐2