JavaScriptβs date/time handling is notoriously messy and libraries like Moment.js became popular as a way to work around it. In 2017, Maggie Johnson-Pint, a maintainer of Moment.js, proposed the Temporal API to fix date/time handling for good, and weβre mostly there (support is growing, with Safari and Node to catch up).
Jason Williams (Bloomberg)
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π3
CHALLENGE
const p1 = new Promise((resolve) => {
console.log("A");
resolve("B");
});
const p2 = p1.then((val) => {
console.log(val);
return "C";
});
p2.then((val) => {
console.log(val);
});
console.log("D");
π5π₯3β€2
β€3π1π₯1
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£5π₯4β€2π2π€1
CHALLENGE
function Vehicle(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
this.describe = function () {
return `${this.year} ${this.make} ${this.model}`;
};
}
Vehicle.prototype.age = function (currentYear) {
return currentYear - this.year;
};
const car = new Vehicle("Toyota", "Supra", 1998);
const bike = new Vehicle("Harley", "Sportster", 2005);
console.log(car.describe());
console.log(bike.age(2025));
console.log(car.constructor === Vehicle);
console.log(Object.getPrototypeOf(car) === Vehicle.prototype);
π4π₯3
What is the output?
Anonymous Quiz
17%
1998 Toyota Supra 27 false true
51%
1998 Toyota Supra 20 true true
19%
1998 Toyota Supra 20 true false
14%
Toyota Supra 1998 27 true true
β€4π2π₯2
Please open Telegram to view this post
VIEW IN TELEGRAM
β€9π₯3π2π€2
CHALLENGE
class EventEmitter {
#listeners = new WeakMap();
#registry = new FinalizationRegistry((label) => {
console.log(`Cleaned up: ${label}`);
});
subscribe(target, callback) {
if (!this.#listeners.has(target)) {
this.#listeners.set(target, []);
}
this.#listeners.get(target).push(callback);
this.#registry.register(target, target.name ?? "unknown");
}
emit(target) {
const cbs = this.#listeners.get(target);
if (cbs) cbs.forEach(cb => cb());
}
}
const emitter = new EventEmitter();
let obj1 = { name: "sensor" };
let obj2 = { name: "timer" };
const ws = new WeakSet([obj1, obj2]);
emitter.subscribe(obj1, () => console.log("sensor fired"));
emitter.subscribe(obj2, () => console.log("timer fired"));
emitter.subscribe(obj1, () => console.log("sensor logged"));
emitter.emit(obj1);
console.log(ws.has(obj1));
obj1 = null;
console.log(ws.has({ name: "sensor" }));β€3π2π₯2
What is the output?
Anonymous Quiz
24%
sensor fired sensor logged true false
32%
sensor fired sensor logged false false
35%
sensor fired timer fired sensor logged true false
9%
sensor fired sensor logged true true
β€5π1
The Node.js team has long been discussing shifting Node to a new schedule of one major release per year (instead of two), removing the odd/even distinction, and making every release LTS (with a prior 11 months of alpha/current status). This is a preview post not intended for final publication till April, so things are subject to change (backup version).
The Node.js Team
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π2π₯2
CHALLENGE
const temperature = {
celsius: 22,
[Symbol.toPrimitive](hint) {
if (hint === 'number') {
return this.celsius;
}
if (hint === 'string') {
return `${this.celsius}Β°C`;
}
return this.celsius + 273.15;
}
};
console.log(`Temp: ${temperature}`);
console.log(temperature + 0);
console.log(temperature * 2);
console.log(+temperature);
β€5π₯5π2
What is the output?
Anonymous Quiz
17%
Temp: 22 295.15 590.3 22
42%
Temp: 22Β°C 295.15 590.3 22
25%
Temp: 22Β°C 295.15 44 22
15%
Temp: 22Β°C 22 44 22
π₯3π1
CHALLENGE
const a = 10n ** 3n;
const b = BigInt(Number.MAX_SAFE_INTEGER) + 1n;
const c = b + 1n;
console.log(typeof a);
console.log(a === 1000n);
console.log(b === c);
console.log(5n / 2n);
β€3π₯3π1
What is the output?
Anonymous Quiz
24%
bigint true true 2.5n
31%
number true false 2n
31%
bigint true false 2n
13%
bigint false false 2n
β€5π1
CHALLENGE
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const pipe = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
const double = x => x * 2;
const addTen = x => x + 10;
const square = x => x * x;
const negate = x => -x;
const transform1 = compose(negate, square, addTen, double);
const transform2 = pipe(double, addTen, square, negate);
const val = 3;
console.log(transform1(val), transform2(val));
π₯6π4β€1
β€3π₯3π2
Over six months in the making, TypeScript 6.0 is designed to bridge the gap between its self-hosted compiler and the (almost ready) Go-powered native compiler of TypeScript 7.0 .
There are new features (Temporal improvements, RegExp.escape, and more), but most important are the changes to help you prepare for 7.0:
β’ Numerous default changes: strict is now true, module is esnext, rootDir defaults to ., and more.
β’ A change that will affect many apps is types defaulting to [] rather than pulling in everything from node_modules/@types.
β’ Numerous deprecations: the es5 target, emitting AMD, UMD, and SystemJS modules, --baseUrl, and others.
β’ --stableTypeOrdering makes 6.0's type ordering behavior match 7.0's to help diagnose inference differences as you update.
Daniel Rosenwasser (Microsoft)
Please open Telegram to view this post
VIEW IN TELEGRAM
β€12π3π₯2
CHALLENGE
const obj = {
name: "Orion",
greet() {
const inner = () => {
console.log(this.name);
};
inner();
},
greetRegular: function () {
const inner = function () {
console.log(this?.name ?? "undefined");
};
inner();
},
};
obj.greet();
obj.greetRegular();
β€2π2π₯2
What is the output?
Anonymous Quiz
30%
Orion Orion
46%
Orion undefined
15%
undefined Orion
8%
undefined undefined
π5β€2
Three reasons your node_modules is huge: needless ES3-era compat packages, micro-libraries with a single consumer, and ponyfills for APIs that shipped years ago! James, known for the e18e ecosystem performance project, offers some ways to calm the chaos.
James Garbutt
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π₯4