Please open Telegram to view this post
VIEW IN TELEGRAM
π4β€1π₯1
CHALLENGE
let obj1 = { id: 1 };
let obj2 = { id: 2 };
let obj3 = { id: 3 };
const weakSet = new WeakSet([obj1, obj2]);
weakSet.add(obj3);
weakSet.delete(obj1);
obj2 = null;
const remainingObjects = [...weakSet];
console.log(remainingObjects);
π2π₯1
What is the output?
Anonymous Quiz
35%
[{ id: 3 }]
34%
TypeError: weakSet is not iterable
28%
[{ id: 2 }, { id: 3 }]
4%
[{ id: 3 }, { id: 2 }]
π9π₯5β€1
CHALLENGE
const secretData = { password: 'abc123' };
const mySet = new WeakSet();
mySet.add(secretData);
// Later in the code
delete secretData.password;
const checkAccess = (obj) => {
console.log(mySet.has(obj));
};
checkAccess(secretData);
checkAccess({ password: 'abc123' });
β€7π2π₯2
π3π₯2β€1
Imagine something like Node.js but really stripped back: bare, if you will. Like Node, itβs built on top of V8 and libuv (though it's designed to support multiple JavaScript engines) but Bareβs approach is to provide as little as possible (a module system, addon system, and thread support) and then rely upon userland modules that can evolve independently of Bare itself. Itβs an interesting idea β more details here.
Holepunch
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π4π₯2
CHALLENGE
async function test() {
console.log('1');
setTimeout(() => {
console.log('2');
}, 0);
await Promise.resolve();
console.log('3');
new Promise(resolve => {
console.log('4');
resolve();
}).then(() => {
console.log('5');
});
console.log('6');
}
test();
console.log('7');
π5β€3π₯1
What is the output?
Anonymous Quiz
29%
1 3 4 5 6 7 2
35%
1 7 3 4 6 5 2
20%
1 7 3 4 5 6 2
15%
1 3 4 6 5 7 2
β€14π€6π3
One of Denoβs compelling features is its support for Jupyter Notebooks and easy notebook-style programming, such as is common in the Python world. Trevor looks at a practical use of using such a notebook environment for data exploration.
Trevor Manz
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π₯2π€©2π1
CHALLENGE
function getCity(person) {
return person?.address?.city ?? 'Unknown';
}
const data = [
null,
{ name: 'Alice' },
{ name: 'Bob', address: null },
{ name: 'Charlie', address: { street: '123 Main' } },
{ name: 'David', address: { city: 'Boston' } }
];
const cities = data.map(getCity);
console.log(cities);
π3β€1
If youβre tired of Web animations, maybe Anime.js will refresh your appetite. This is a major upgrade to a mature library for animating CSS properties, SVGs, the DOM, and JS objects. Itβs smooth, well-built, and now complete with fresh documentation.
Julian Garner
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π5π₯4
CHALLENGE
const p1 = Promise.resolve(1);
const p2 = new Promise(resolve => resolve(2));
const p3 = new Promise(resolve => setTimeout(() => resolve(3), 0));
const p4 = Promise.reject(4).catch(err => err);
Promise.all([p1, p2, p3, p4])
.then(values => {
const result = values.reduce((acc, val) => {
return acc + val;
}, 0);
console.log(result);
})
.catch(err => console.log('Error:', err));
β€5π1
β€7π€5π2
CHALLENGE
const obj = {
[Symbol('a')]: 'hidden',
[Symbol.for('b')]: 'registered',
c: 'normal'
};
const symbols = Object.getOwnPropertySymbols(obj);
const keys = Object.keys(obj);
const allProps = Reflect.ownKeys(obj);
console.log(symbols.length, keys.length, allProps.length);
π3β€2
π8β€5π₯2π€£2π€1
A detailed guide to modern testing in Node from a group of developers who know all about it. Itβs on GitHub but is essentially written like a free book covering over 50 battle-tested tips covering areas as diverse as the βTesting Diamondβ, testing microservices, checking contracts, verifying OpenAPI correctness, and simulating flaky network conditions.
Goldberg, Salomon, and Gluskin
Please open Telegram to view this post
VIEW IN TELEGRAM
π9π₯3β€2
CHALLENGE
function createCounter() {
let count = 0;
return function() {
count++;
return count;
};
}
const counter1 = createCounter();
const counter2 = createCounter();
counter1();
counter1();
counter2();
const result = counter1() + counter2();
console.log(result);
π8π€8β€4
π€10