What is the output?
Anonymous Quiz
24%
dagger [ 'sword', 'bow' ]
49%
dagger ["sword", "bow"]
16%
sword ["bow"]
10%
bow ["dagger", "sword"]
โค1๐1
Please open Telegram to view this post
VIEW IN TELEGRAM
๐คฃ13โค3๐2๐ฅ2
CHALLENGE
const handler = {
get(target, prop, receiver) {
if (prop in target) {
return Reflect.get(target, prop, receiver) * 2;
}
return `missing:${prop}`;
},
set(target, prop, value) {
if (typeof value !== "number") {
throw new TypeError("Only numbers allowed");
}
return Reflect.set(target, prop, value * 10);
},
has(target, prop) {
return prop.startsWith("x") ? false : prop in target;
},
};
const store = new Proxy({ xRay: 5, score: 3 }, handler);
store.level = 4;
console.log(store.xRay);
console.log(store.score);
console.log(store.level);
console.log("xRay" in store);
console.log("score" in store);
console.log(store.missing);
๐3โค2
CHALLENGE
const inventory = {
warehouse: {
shelves: [
{ id: 'A1', items: ['bolts', 'nuts', 'washers'] },
{ id: 'B2', items: ['hammers', 'wrenches'] },
],
manager: { name: 'Carlos', shift: 'night' },
},
};
const {
warehouse: {
shelves: [{ items: [firstItem, , thirdItem] }, { id: shelfId }],
manager: { name, shift = 'day' },
},
} = inventory;
console.log(`${name} | ${shift} | ${shelfId} | ${firstItem} | ${thirdItem}`);๐คฃ4โค1
CHALLENGE
async function fetchData(id) {
if (id <= 0) throw new Error("Invalid ID");
return { id, value: id * 10 };
}
async function process() {
const results = await Promise.allSettled([
fetchData(1),
fetchData(-1),
fetchData(3),
]);
results.forEach(({ status, value, reason }) => {
if (status === "fulfilled") {
console.log(`โ
${value.id}: ${value.value}`);
} else {
console.log(`โ ${reason.message}`);
}
});
}
process();โค5
What is the output?
Anonymous Quiz
25%
โ
1: 10 โ Error: Invalid ID โ
3: 30
50%
โ
1: 10 โ Invalid ID โ
3: 30
21%
โ
1: 10 โ
3: 30
4%
โ Invalid ID โ
1: 10 โ
3: 30
โค2๐1
CHALLENGE
const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);
const pipe = (...fns) => x => fns.reduce((acc, fn) => fn(acc), x);
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(negate, square, addTen, double);
console.log(transform1(3));
console.log(transform2(3));
โค1๐1
๐ค2๐1๐ฅ1
CHALLENGE
const setA = new Set([1, 2, 3, 4, 5]);
const setB = new Set([3, 4, 5, 6, 7]);
const union = new Set([...setA, ...setB]);
const intersection = new Set([...setA].filter(x => setB.has(x)));
const differenceAB = new Set([...setA].filter(x => !setB.has(x)));
const symmetricDiff = new Set(
[...setA, ...setB].filter(x => !(setA.has(x) && setB.has(x)))
);
console.log([...union].join(','));
console.log([...intersection].join(','));
console.log([...differenceAB].join(','));
console.log([...symmetricDiff].join(','));
โค2๐ฅ1
What is the output?
Anonymous Quiz
28%
1,2,3,4,5,6,7 3,4,5 6,7 1,2,6,7
47%
1,2,3,4,5,6,7 3,4,5 1,2 1,2,6,7
19%
1,2,3,4,5,6,7 4,5 1,2 1,2,6,7
6%
1,2,3,4,5,6,7 3,4,5 1,2,3 1,2,3,6,7
โค1
Vite+ is the Vite teamโs โunified toolchainโ that brings Vite, Vitest, Oxlint, and similar tools together under a single vp command, whether for running a dev server, tests, formatting, or bundling.
VoidZero
Please open Telegram to view this post
VIEW IN TELEGRAM
๐4โค2
CHALLENGE
const compose = (...fns) => x => fns.reduceRight((acc, fn) => fn(acc), x);
const pipe = (...fns) => x => fns.reduce((acc, fn) => fn(acc), x);
const double = x => x * 2;
const addTen = x => x + 10;
const square = x => x ** 2;
const negate = x => -x;
const transform1 = compose(negate, square, addTen, double);
const transform2 = pipe(negate, square, addTen, double);
console.log(transform1(3));
console.log(transform2(3));
๐3โค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
๐4โค1๐ฅ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);