Landing just two days after 26.6, coverage reports can now include files your tests didn't touch with
--test-coverage-include-all, FFI and SQLite pick up crash fixes, and Perfetto tracing support lands, though you'll need a custom build to use it.Antoine du Hamel
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4👍4🔥1
CHALLENGE
const arr = [1, 2, 3, 4, 5];
arr[Symbol.iterator] = function* () {
for (let i = 0; i < 3; i++) yield arr[i] * 2;
};
console.log([...arr], JSON.stringify(arr));
👍2🔥2❤1
What is the output?
Anonymous Quiz
22%
[ 1, 2, 3 ] [1,2,3,4,5]
38%
[ 2, 4, 6, 8, 10 ] [1,2,3,4,5]
19%
[ 2, 4, 6 ] [2,4,6,4,5]
20%
[ 2, 4, 6 ] [1,2,3,4,5]
👍1🔥1
A Rust-powered library (with Node.js and WASM bindings) that converts Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, and PDF documents into Markdown. I tried it on a 1,600 page PDF and it took less than 2 seconds. There's also an in-browser demo to try it out. GitHub repo.
Firecrawl
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3🔥2❤1
CHALLENGE
function test() {
try {
console.log(y);
} catch (e) {
return e.constructor.name;
}
}
let result1 = test();
let y = 'hoisted';
console.log(result1, typeof y, y);🔥5👍1
What is the output?
Anonymous Quiz
35%
ReferenceError string hoisted
28%
ReferenceError undefined hoisted
30%
undefined string hoisted
7%
TypeError string hoisted
🔥3❤1👍1
Did you know JavaScript supports a third type of comment (beyond // and /* */)? 😉 Mat Marquis shows off hashbang comments in a short YouTube video. And yes, they're in the language spec!
Please open Telegram to view this post
VIEW IN TELEGRAM
🤔6❤2🔥2👍1
CHALLENGE
const obj = { a: { b: null }, getVal: null };
let counter = 0;
function sideEffect() {
counter++;
return counter;
}
const result = obj?.a?.b?.[sideEffect()] ?? 'default1';
const result2 = obj.getVal?.(sideEffect()) ?? 'default2';
const result3 = obj?.a?.c?.d ?? sideEffect();
console.log(result, result2, result3, counter);👍3🔥3❤1
What is the output?
Anonymous Quiz
26%
default1 default2 undefined 0
31%
1 2 1 1
31%
default1 default2 1 1
12%
default1 default2 default3 0
🔥5❤3👍1
CHALLENGE
const key = 'greet';
const name = 'world';
const obj = {
name,
[key]() { return `Hello, ${this.name}`; },
[`${key}Arrow`]: () => `Hello, ${this?.name}`,
};
console.log(`${obj.greet()} | ${obj.greetArrow()}`);
❤3👍3
What is the output?
Anonymous Quiz
29%
Hello, world | Hello, world
40%
Hello, world | Hello, undefined
15%
Hello, undefined | Hello, world
16%
Hello, undefined | Hello, undefined
👍4
Over several years, Yelp moved 1.4 million lines off Flow, and this writeup is more useful as a guide to running any long migration than as a Flow story. It was a big win on its own terms, with type coverage up from 83% to 96%.
Shawn Walton (Yelp)
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3❤2
CHALLENGE
function combine(a, b = 10, ...rest) {
return JSON.stringify([a, b, rest]);
}
const inputs = [1, undefined, 3, 4, 5];
console.log(combine(...inputs));❤5👍3
What is the output?
Anonymous Quiz
31%
[1,10,3,4,5]
21%
[1,10,[3,4,5,5]]
30%
[1,undefined,[3,4,5]]
18%
[1,10,[3,4,5]]
❤3👍3
The js1024 code golfing contest is over and we have three winners! Skydreams, a Super Monkey Ball-like experience, came in first place. You can read the readable and minified source if you want to see the techniques used.
🔥7❤4
CHALLENGE
function curry(fn) {
return function curried(...args) {
if (args.length >= fn.length) {
return fn.apply(this, args);
}
return (...more) => curried.apply(this, args.concat(more));
};
}
function add(a, b, c = 10) {
return a + b + c;
}
const curriedAdd = curry(add);
console.log(`${curriedAdd(1)(2)} ${curriedAdd(1,2,3)} ${curriedAdd(4)(5,6)}`);👍3❤2🔥1
👍4
Like the look of Ink but don't like React? TermDOM implements a DOM, cascade and layout engine that paints to the terminal, so you can write a TUI with HTML and CSS. Pure JS, no native or WASM dependencies, and the official TodoMVC runs with only a stylesheet swap. Early days, but I like the idea!
Brian Kim
Please open Telegram to view this post
VIEW IN TELEGRAM
❤5👍3🤔2
CHALLENGE
const log = [];
Promise.resolve(1)
.then(v => { log.push('a'+v); return v+1; })
.then(v => { throw new Error('e'+v); })
.catch(e => { log.push(e.message); return 10; })
.then(v => { log.push('b'+v); });
Promise.resolve()
.then(() => log.push('c'))
.then(() => log.push('d'));
setTimeout(() => console.log(log.join(',')), 0);
🔥7❤1
What is the output?
Anonymous Quiz
19%
c,d,a1,e2,b10
41%
a1,c,d,e2,b10
23%
a1,c,d,b10,e2
17%
a1,c,e2,d,b10
👍1