π3β€1π€©1π€£1
With Eloquent JavaScript and ProseMirror under his belt, not many people know more about JavaScript and making good editor controls than Marijn. Modular, supports collaborative editing, and thoughtfully built. Live demo and how to get started.
Marijn Haverbeke
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π₯2
A minor release whose headline feature is the (experimental) implementation of package maps (which let Node resolve packages from a static JSON file rather than walking node_modules). Matteo Collinaβs node:vfs subsystem also begins to make an appearance.
Antoine du Hamel
Please open Telegram to view this post
VIEW IN TELEGRAM
π5β€3π₯1
CHALLENGE
class Pipeline {
#value;
#steps = [];
constructor(value) {
this.#value = value;
}
map(fn) {
this.#steps.push({ type: 'map', fn });
return this;
}
filter(fn) {
this.#steps.push({ type: 'filter', fn });
return this;
}
execute() {
return this.#steps.reduce((acc, step) => {
if (step.type === 'map') return acc.map(step.fn);
if (step.type === 'filter') return acc.filter(step.fn);
return acc;
}, this.#value);
}
}
const result = new Pipeline([1, 2, 3, 4, 5, 6])
.filter(x => x % 2 === 0)
.map(x => x ** 2)
.filter(x => x > 10)
.map(x => x - 1)
.execute();
console.log(result);π4β€1π₯1
β€1π₯1
A new framework from Vercel that provides Next.js-esque structure for building AI-powered agents using TypeScript and Markdown. It's quite Vercel-flavored by default, but I found you can run it entirely independently of Vercel with a few settings tweaks and your own keys. Project homepage.
Vercel
Please open Telegram to view this post
VIEW IN TELEGRAM
β€3π₯2
CHALLENGE
console.log('start');
setTimeout(() => console.log('timeout 1'), 0);
Promise.resolve()
.then(() => {
console.log('promise 1');
setTimeout(() => console.log('timeout 2'), 0);
})
.then(() => console.log('promise 2'));
setTimeout(() => console.log('timeout 3'), 0);
queueMicrotask(() => console.log('microtask'));
console.log('end');β€4π₯3π2
What is the output?
Anonymous Quiz
30%
start end promise 1 microtask promise 2 timeout 1 timeout 3 timeout 2
38%
start end promise 1 promise 2 microtask timeout 1 timeout 3 timeout 2
21%
start end microtask promise 1 promise 2 timeout 1 timeout 2 timeout 3
11%
start end timeout 1 timeout 3 promise 1 microtask promise 2 timeout 2
β€4π₯1
CHALLENGE
const curry = (fn) => {
const arity = fn.length;
return function curried(...args) {
if (args.length >= arity) {
return fn(...args);
}
return (...moreArgs) => curried(...args, ...moreArgs);
};
};
const volume = (l, w, h) => l * w * h;
const curriedVolume = curry(volume);
const withLength5 = curriedVolume(5);
const withLength5Width3 = withLength5(3);
console.log(typeof withLength5);
console.log(typeof withLength5Width3);
console.log(withLength5Width3(2));
console.log(curriedVolume(5)(3)(2) === withLength5(3)(2));
β€3π₯3π1
What is the output?
Anonymous Quiz
21%
function function 30 false
27%
object function 30 true
36%
function function 30 true
17%
function number 30 true
π₯2β€1
CHALLENGE
const obj = {
name: "Quantum",
regular: function () {
return this.name;
},
arrow: () => {
return this?.name;
},
nested: function () {
const inner = () => this.name;
return inner();
},
};
console.log(obj.regular());
console.log(obj.arrow());
console.log(obj.nested());π4β€3π₯3
What is the output?
Anonymous Quiz
19%
undefined undefined Quantum
28%
Quantum Quantum Quantum
24%
Quantum undefined undefined
30%
Quantum undefined Quantum
π₯2π€£1
CHALLENGE
const flags = {
READ: 0b0001,
WRITE: 0b0010,
EXECUTE: 0b0100,
DELETE: 0b1000,
};
const userPermissions = flags.READ | flags.WRITE | flags.EXECUTE;
const adminPermissions = userPermissions | flags.DELETE;
const canDelete = (adminPermissions & flags.DELETE) !== 0;
const readOnly = userPermissions & ~flags.WRITE;
const toggled = userPermissions ^ flags.EXECUTE;
const shifted = (flags.DELETE << 2) | (flags.READ >> 0);
console.log(canDelete, readOnly, toggled, shifted);β€2π2π₯1
π€3β€1
CHALLENGE
function createUser(
name,
role = "viewer",
permissions = { read: true, write: false },
level = permissions.write ? 2 : 1
) {
return { name, role, permissions, level };
}
const user1 = createUser("Carlos");
const user2 = createUser("Diana", "editor", { read: true, write: true });
const user3 = createUser("Eve", "admin", undefined, 5);
console.log(user1.role, user1.level);
console.log(user2.role, user2.level);
console.log(user3.role, user3.level);
π₯5π€©2π1
What is the output?
Anonymous Quiz
16%
viewer 2 editor 2 admin 5
32%
viewer 1 editor 1 admin 5
39%
viewer 1 editor 2 admin 5
13%
viewer 1 editor 2 admin 2
β€3π1
CHALLENGE
const user = {
profile: {
name: "Marcus",
address: {
city: "Berlin",
zip: "10115"
}
},
getSubscription: () => ({
plan: "pro",
features: ["analytics", "exports"]
})
};
const city = user?.profile?.address?.city;
const country = user?.profile?.address?.country?.toUpperCase();
const firstFeature = user?.getSubscription?.()?.features?.[0];
const adminRole = user?.roles?.[0]?.name ?? "guest";
console.log(city, country, firstFeature, adminRole);π₯4π3π€©2β€1
What is the output?
Anonymous Quiz
20%
undefined undefined undefined guest
29%
Berlin null analytics null
43%
Berlin undefined analytics guest
8%
Berlin undefined undefined guest
π₯1
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£9π₯6π€1