What is the output?
Anonymous Quiz
30%
Hello, Sarah Hello, Sarah Hello, Mike Hello, Sarah
24%
Hello, Sarah Hello, Mike Hello, Mike Hello, Mike
19%
Hello, Sarah Hello, Hello, Mike Hello, Mike
27%
Hello, Sarah Hello, undefined Hello, Mike Hello, Mike
π6β€2π€£2π₯1
CHALLENGE
const source = { a: 1, b: { c: 2 } };
const target1 = Object.assign({}, source);
const target2 = { ...source };
source.b.c = 99;
target1.a = 10;
target2.b.c = 50;
console.log(source.a);
console.log(source.b.c);
console.log(target1.a);
console.log(target1.b.c);
console.log(target2.a);
console.log(target2.b.c);β€5π4π₯3
What is the output?
Anonymous Quiz
30%
1 50 10 50 1 50
29%
10 99 10 99 10 99
17%
1 2 10 2 1 2
23%
1 99 10 99 1 99
β€5π3π₯2
Four stalwarts of the JavaScript ecosystem all shipped notable releases this week, and odds are you're using at least one of them:
β’ Gatsby v5.16 proves Gatsby, once considered neck-and-neck with Next.js in the React world, is not 'dead'. The headline feature is React 19 support.
β’ Babel 7 just shipped its final release. "After years in the making, Babel 8 is finally ready," in release candidate form, at least.
β’ Rspress 2.0 is a major release for the high-performance Rust-powered, but JavaScript-facing, static site generator.
β’ Lodash 4.17.23 sounds minor, but it's a 'security reset' for the still heavily used utility library and is designed to provide a base for a longer future.
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯9π5β€4
CHALLENGE
const memoize = (fn) => {
const cache = new Map();
return (...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(10));
console.log(fibonacci(5));
console.log(fibonacci(10));π₯8β€4π2
β€2π₯2π1
Why use a proper locale-aware API to parse numbers when you can hand-roll a maze of string splits, separator swaps, and implicit type coercions that silently break on edge cases?
Remy Porter (The Daily WTF)
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π₯6π3
CHALLENGE
let counter = 0;
const increment = () => ++counter;
const getValue = () => counter;
const obj = {
get value() {
increment();
return getValue();
}
};
console.log(obj.value);
console.log(obj.value);
console.log(counter);
β€8π₯5π2
β€2π2π₯1
Generate customized interactive heatmaps (think GitHub contributions graph), or render heatmaps as lines and bar charts. The site is packed with demos to enjoy. GitHub repo.
William Troup
Please open Telegram to view this post
VIEW IN TELEGRAM
β€9π₯8π5
CHALLENGE
const target = { name: "Sarah", age: 25 };
const handler = {
get(obj, prop) {
if (prop === 'greeting') {
return `Hello, I'm ${obj.name}`;
}
return obj[prop]?.toString().toUpperCase() || 'UNKNOWN';
},
set(obj, prop, value) {
if (typeof value === 'string') {
obj[prop] = value.toLowerCase();
} else {
obj[prop] = value * 2;
}
return true;
}
};
const proxy = new Proxy(target, handler);
console.log(proxy.name);
proxy.city = "Boston";
proxy.score = 15;
console.log(proxy.greeting);
console.log(proxy.city + " " + proxy.score);π16β€6π₯4
What is the output?
Anonymous Quiz
30%
SARAH Hello, I'm Sarah boston 30
32%
sarah Hello, I'm Sarah boston 15
18%
SARAH Hello, I'm sarah boston 30
20%
SARAH Hello, I'm Sarah BOSTON 30
β€5π1
Please open Telegram to view this post
VIEW IN TELEGRAM
π7β€5π₯4
CHALLENGE
class DataProcessor {
static #cache = new Map();
static #initialized = false;
static {
console.log('First block');
this.#cache.set('default', 'value1');
}
static {
console.log('Second block');
this.#cache.set('config', 'value2');
this.#initialized = true;
}
static getStatus() {
return `${this.#cache.size}-${this.#initialized}`;
}
}
console.log(DataProcessor.getStatus());π4β€3
What is the output?
Anonymous Quiz
25%
Second block First block 2-true
28%
First block Second block 2-false
16%
2-true First block Second block
31%
First block Second block 2-true
π3β€1
LibPDF bills itself as βthe PDF library TypeScript deservesβ and supports parsing, modifying, signing and generating PDFs with a modern API in Node, Bun, and the browser. GitHub repo.
Documenso
Please open Telegram to view this post
VIEW IN TELEGRAM
π10β€9π₯4
CHALLENGE
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { ...obj1 };
const obj3 = obj1;
obj2.a = 10;
obj2.b.c = 20;
obj3.b.c = 30;
console.log(obj1.a);
console.log(obj1.b.c);
console.log(obj2.a);
console.log(obj2.b.c);
console.log(obj3.a);
console.log(obj3.b.c);β€5π1π₯1
What is the output?
Anonymous Quiz
37%
1 30 10 30 1 30
26%
1 20 10 20 1 20
24%
1 2 10 20 1 2
13%
10 20 10 20 10 20
β€5π₯3π1
The results of the popular annual JavaScript survey are out, and weβre focusing on the most relevant bit to Node.js: backend frameworks. Express still leads the way, but NestJS continues to grow rapidly. Meanwhile, Hono comes top in developer satisfaction.
Devographics
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π4π₯3
CHALLENGE
function memoize(fn) {
const cache = new Map();
return function(...args) {
const key = JSON.stringify(args);
if (cache.has(key)) {
return cache.get(key);
}
const result = fn.apply(this, args);
cache.set(key, result);
return result;
};
}
const fibonacci = memoize(function(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
});
console.log(fibonacci(10));
console.log(fibonacci.cache?.size || 'undefined');π₯5π3β€1