CHALLENGE
function processUserData(data) {
const settings = {
theme: data.preferences?.theme ?? 'light',
notifications: data.preferences?.notifications ?? true,
fontSize: data.preferences?.fontSize ?? 16
};
let status = data.status ?? 'active';
let reputation = data.reputation ?? 0;
console.log(reputation || 'No reputation yet');
return settings;
}
processUserData({ status: '', reputation: 0 });
โค3๐3๐ค1
โค5๐4๐ค4๐ฅ1
Electron is a natural choice for building JS and HTML-powered cross-platform desktop apps but numerous alternatives have appeared like Neutralinojs and the Rust-based Tauri. This post does a good job of quickly showing how Tauri differs and why you might choose it.
Costa Alexoglou
Please open Telegram to view this post
VIEW IN TELEGRAM
๐4๐ฅ2โค1
CHALLENGE
type User = {
id: number;
name: string;
email?: string;
};
function processUser<T extends User>(user: T): T & { processed: boolean } {
return { ...user, processed: true };
}
const partialUser = { id: 1, name: 'Alice' };
const result = processUser(partialUser);
console.log(typeof result.email);
๐8๐ฅ3โค1
What is the output?
Anonymous Quiz
19%
object
26%
string
28%
Error: Property 'email' does not exist on type 'User'
27%
undefined
โค4๐2๐ฅ2๐คฉ1
Cursor's new "pay as you go" strategy with better models drives 20-30% more code generation than you would typically do. For all of the "vibe coders" out there, this is becoming an exponential "coding tax" for products because more code equals more token consumption, which generates more code...
Tigran Bayburtsyan
Please open Telegram to view this post
VIEW IN TELEGRAM
๐คฃ17๐4โค3๐ค1
CHALLENGE
const num1 = 9007199254740992n;
const num2 = 1n;
const result1 = num1 + num2;
const result2 = Number(num1) + Number(num2);
const result3 = num1 + BigInt(1);
const result4 = String(num1) + String(num2);
console.log(typeof result2 === typeof result1, result1 === result3, result4);
๐2
What is the output?
Anonymous Quiz
27%
false false "90071992547409921"
30%
true true "90071992547409921"
27%
false true 9007199254740993n
16%
false true "90071992547409921"
๐6โค4๐ฅ2
๐ต๏ธ ๐ช๐ฒ ๐ฐ๐ฎ๐๐ด๐ต๐ ๐ฐ๐ต๐๐ฎ๐๐ฎ๐ฟ๐๐ ๐๐ฎ๐ฐ๐ธ๐ถ๐ป๐ด ๐๐ฟ๐ผ๐๐ฝ ๐ฑ๐ฒ๐ฏ๐๐ด๐ด๐ถ๐ป๐ด ๐๐ต๐ฒ๐ถ๐ฟ ๐ผ๐๐ป ๐บ๐ฎ๐น๐๐ฎ๐ฟ๐ฒ... ๐ถ๐ป ๐ฟ๐ฒ๐ฎ๐น ๐๐ถ๐บ๐ฒ.
A couple of weeks ago, something unexpected happened. While monitoring malicious uploads to the NPM ecosystem, we stumbled on a suspicious package: react-html2pdf.js (now suspended). At first glance, it looked innocuous. ๐ก๐ผ ๐น๐ถ๐ณ๐ฒ๐ฐ๐๐ฐ๐น๐ฒ ๐ต๐ผ๐ผ๐ธ๐. ๐ก๐ผ ๐ผ๐ฏ๐๐ถ๐ผ๐๐ ๐บ๐ฎ๐น๐๐ฎ๐ฟ๐ฒ. Just a basic function in the index.js file.
Mackenzie Jackson
A couple of weeks ago, something unexpected happened. While monitoring malicious uploads to the NPM ecosystem, we stumbled on a suspicious package: react-html2pdf.js (now suspended). At first glance, it looked innocuous. ๐ก๐ผ ๐น๐ถ๐ณ๐ฒ๐ฐ๐๐ฐ๐น๐ฒ ๐ต๐ผ๐ผ๐ธ๐. ๐ก๐ผ ๐ผ๐ฏ๐๐ถ๐ผ๐๐ ๐บ๐ฎ๐น๐๐ฎ๐ฟ๐ฒ. Just a basic function in the index.js file.
Mackenzie Jackson
๐ค6๐คฃ6โค2
CHALLENGE
function createSymbolDemo() {
const obj = {};
const sym1 = Symbol('description');
const sym2 = Symbol('description');
const sym3 = Symbol.for('shared');
const sym4 = Symbol.for('shared');
obj[sym1] = 'Value 1';
obj[sym2] = 'Value 2';
obj[sym3] = 'Value 3';
obj[sym4] = 'Value 4';
console.log(Object.keys(obj).length, sym1 === sym2, sym3 === sym4, obj[sym3]);
}
createSymbolDemo();
๐6
What is the output?
Anonymous Quiz
21%
0 false true Value 4
31%
4 true true Value 4
35%
4 false false Value 3
13%
0 false true Value 3
๐ค9๐3โค2
Please open Telegram to view this post
VIEW IN TELEGRAM
๐คฃ55โค5๐คฉ4๐2
CHALLENGE
function* generateSequence() {
let i = 1;
while (i <= 3) {
yield i++;
}
}
function* extendSequence() {
yield* generateSequence();
yield* [4, 5];
yield 6;
}
const generator = extendSequence();
const result = [];
for (const value of generator) {
if (value % 2 === 0) {
result.push(value * 2);
} else {
result.push(value);
}
}
console.log(result);
โค1
What is the output?
Anonymous Quiz
15%
[1, 4, 3, 8, 5, 6]
44%
[1, 4, 3, 8, 5, 12]
28%
[1, 2, 3, 4, 5, 6]
13%
[1, 4, 3, 8, 10, 12]
๐6๐ฅ5โค2๐ค1
Nodeโs Fastify framework has a mature plugin for Vite integration (explained in detail here), including @fastify/react which just hit version 1.0 and makes it easy to create fast, featureful (though obviously less so than Next.js) React apps atop Fastify. How fast? Very, it seems.
Jonas Galvez
Please open Telegram to view this post
VIEW IN TELEGRAM
๐ค6โค3๐2๐ฅ1
CHALLENGE
const privateData = new WeakMap();
function Person(name) {
privateData.set(this, { name, secretCount: 0 });
this.greet = function() {
const data = privateData.get(this);
data.secretCount++;
return `Hello, my name is ${data.name}`;
};
this.getSecretCount = function() {
return privateData.get(this).secretCount;
};
}
const alice = new Person('Alice');
alice.greet();
alice.greet();
const result = [
privateData.has(alice),
alice.name,
alice.getSecretCount()
];
console.log(result);
๐4โค1
What is the output?
Anonymous Quiz
31%
[true, undefined, 2]
27%
[false, undefined, 2]
16%
[Object, undefined, 2]
26%
[true, 'Alice', 2]
1๐5โค2๐ฅ1
Node actually has a mechanism for creating single executable applications and there are numerous other tools to do it, but Lexe takes the approach of using Amazonโs lightweight LLRT engine to make binaries of under 10MB in size. Note, however, "Lexe is not a drop-in replacement for Node.js. It only supports a subset of Node.js APIs."
Ray-D-Song
Please open Telegram to view this post
VIEW IN TELEGRAM
๐6โค3๐ฅ1
Please open Telegram to view this post
VIEW IN TELEGRAM
2๐คฃ37โค4๐ฅ4๐1
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