PGlite packages a WASM build of Postgres into a TypeScript library that can be run directly from Node.js (or Bun, Deno, and even the browser) and itβs only a few megabytes in size.
ElectricSQL / Neon
Please open Telegram to view this post
VIEW IN TELEGRAM
π5β€2π₯2
CHALLENGE
function outer() {
let x = 10;
function inner() {
console.log(x);
if(true) {
let x = 20;
console.log(x);
}
console.log(x);
}
inner();
}
outer();
π7β€1
What is the output?
Anonymous Quiz
15%
undefined, 20, 10
16%
10, 20, undefined
55%
10, 20, 10
14%
10, 20, 20
π11β€3π₯1
A tool that runs pnpm inside your browser, βinstallsβ a package, then analyzes its dependencies. This can be useful for analyzing packages you already use, but also for simplifying your own projects, as 11tyβs Zach Leatherman did here.
Anthony Fu
Please open Telegram to view this post
VIEW IN TELEGRAM
β€10π6π₯1
CHALLENGE
const ws = new WeakSet();
const obj1 = { id: 1 };
const obj2 = { id: 2 };
ws.add(obj1);
ws.add(obj2);
ws.delete(obj1);
const obj3 = { id: 2 };
console.log([
ws.has(obj2),
ws.has(obj1),
ws.has(obj3),
ws.has({ id: 2 })
]);
π8π₯2
What is the output?
Anonymous Quiz
16%
[false, false, false, false]
38%
[true, false, false, false]
14%
[true, true, true, false]
32%
[true, false, true, true]
π8π₯3β€2π€2π€£1
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π2π₯2
CHALLENGE
class Task {
constructor(name) {
this.name = name;
}
async execute() {
const result = await Promise.resolve(this.name);
return { result };
}
}
const task = new Task('test');
task.execute().then(console.log);
π₯7π2
What is the output?
Anonymous Quiz
40%
test
17%
{ result: undefined }
15%
Promise { <pending> }
28%
{ result: 'test' }
π8β€4π₯2
It looks deceptively simple β just 14 characters of JavaScript β but after working with JavaScript for 29 years, I got it wrong. A clue: it goes back to a browser-related quirk from 30 years ago..
Hillel Wayne
Please open Telegram to view this post
VIEW IN TELEGRAM
π3β€2π₯1
CHALLENGE
const users = [
{ id: 1, name: 'Alice', age: 25 },
{ id: 2, name: 'Bob', age: 30 },
{ id: 3, name: 'Charlie', age: 35 }
];
const result = users
.filter(user => user.age > 25)
.map(user => user.name.toUpperCase())
.reduce((acc, name) => acc + name[0], '');
console.log(result);
π3π₯2β€1
π15π€£12π₯5β€2π€2
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£109π9β€2
CHALLENGE
async function getData() {
return Promise.resolve(1);
}
async function process() {
try {
const x = await getData();
const y = await Promise.resolve(x + 1);
console.log(y + await Promise.resolve(1));
} catch(err) {
console.log('Error');
}
}
process();
π5β€3π₯1π€1π€£1
π€£9π€5β€2
CHALLENGE
const cache = new WeakMap();
const obj1 = { id: 1 };
const obj2 = { id: 2 };
cache.set(obj1, 'data1');
cache.set(obj2, 'data2');
obj2.newProp = 'test';
console.log(cache.has(obj1), cache.has(obj2), cache.has({ id: 1 }));
π3
What is the output?
Anonymous Quiz
13%
false true false
29%
true false true
54%
true true false
5%
true false false
π11π€£5β€2π₯1
Please open Telegram to view this post
VIEW IN TELEGRAM
β€13π₯4π2
CHALLENGE
const counter = {
count: 0,
increment() {
this.count++;
return this.count;
}
};
const inc = counter.increment;
const boundInc = counter.increment.bind(counter);
console.log([
counter.increment(),
inc(),
boundInc(),
counter.count
]);
π8β€1
What is the output?
Anonymous Quiz
35%
[1, 1, 2, 1]
25%
[1, NaN, 2, 2]
32%
[1, undefined, 2, 2]
7%
[1, NaN, 1, 1]
π10β€1π₯1