CHALLENGE
const companies = [
{ name: 'TechCorp', founded: 2010 },
{ name: 'DataSystems', founded: 2015 },
{ name: 'WebSolutions', founded: 2008 }
];
const activeClients = new WeakSet();
activeClients.add(companies[0]);
activeClients.add(companies[2]);
companies.pop();
const result = [
activeClients.has(companies[0]),
activeClients.has(companies[1]),
typeof activeClients.size
];
console.log(result);
โค4๐1๐ค1
What is the output?
Anonymous Quiz
40%
[true, false, 'number']
26%
[true, true, 'undefined']
28%
[true, false, 'undefined']
5%
[false, true, 'undefined']
โค2๐ค2
CHALLENGE
function processConfig(config) {
const defaults = {
timeout: 1000,
retries: 3,
enabled: false,
count: 0
};
const settings = {
...defaults,
...config
};
const effectiveTimeout = settings.timeout ?? 500;
const effectiveRetries = settings.retries ?? 1;
const effectiveEnabled = settings.enabled ?? true;
const effectiveCount = settings.count ?? 5;
console.log([effectiveTimeout, effectiveRetries, effectiveEnabled, effectiveCount]);
}
processConfig({ timeout: null, retries: 0, enabled: undefined });
๐5๐ค1
What is the output?
Anonymous Quiz
20%
[null, 0, true, 0]
43%
[500, 0, true, 0]
29%
[500, 1, true, 5]
8%
[null, 0, true, 5]
๐ฅ7โค5๐1๐ค1
Please open Telegram to view this post
VIEW IN TELEGRAM
๐5๐ฅ3โค2
CHALLENGE
console.log('Start');
setTimeout(() => {
console.log('Timeout 1');
}, 0);
Promise.resolve().then(() => {
console.log('Promise 1');
}).then(() => {
console.log('Promise 2');
});
setTimeout(() => {
console.log('Timeout 2');
}, 0);
console.log('End');
โค4
This ~420pg ebook is a collection of all 4 remaining "unbooks" of the 2nd edition of "You Don't Know JS Yet" book series.
Kyle Simpson
Please open Telegram to view this post
VIEW IN TELEGRAM
1๐10โค4๐ฅ4๐ค1
CHALLENGE
const a = 9007199254740991n;
const b = 2n;
function performCalculation() {
const c = a + 1n;
const d = c / b;
const e = d * 2n - 1n;
const result = Number(e) === Number(a);
console.log(result);
}
performCalculation();
๐7
What is the output?
Anonymous Quiz
30%
true
24%
false
20%
9007199254740991
26%
TypeError: Cannot convert a BigInt value to a number
๐11๐ค6โค4
CHALLENGE
const obj = {
[Symbol('a')]: 'hidden',
a: 'visible',
[Symbol.for('b')]: 'registered',
b: 123
};
const symbol1 = Symbol.for('b');
const symbol2 = Symbol.for('b');
console.log(obj.a + ', ' +
obj[Symbol('a')] + ', ' +
obj[symbol1] + ', ' +
(symbol1 === symbol2));
โค2๐ฅ2๐1
What is the output?
Anonymous Quiz
38%
visible, hidden, registered, true
38%
visible, undefined, registered, true
14%
visible, undefined, registered, false
10%
visible, hidden, undefined, true
๐7โค5๐ฅ4
A popular Processing-inspired creative coding library that makes it easy to create interactive, visual experiences (examples). v2.0 improves its font support, adds more ways to draw and manipulate text, adds a way to write shaders in JavaScript, and much more. p5.js 2.0: You Are Here has more details on the release and where the project is headed next.
p5.js Team
Please open Telegram to view this post
VIEW IN TELEGRAM
๐7๐ฅ2โค1
CHALLENGE
function* counter() {
let i = 0;
while (true) {
const direction = yield i;
if (direction === 'up') i += 2;
else if (direction === 'down') i -= 1;
else i += 1;
}
}
const count = counter();
console.log(count.next().value);
console.log(count.next('up').value);
console.log(count.next('down').value);
console.log(count.next().value);
๐1๐ฅ1
๐4โค3๐ฅ3
A split-flap display is a electro-mechanical display commonly associated with live timetable displays and it makes for a neat effect on the Web too. Jhey breaks down how to replicate it, or you can hit up this live demo.
Jhey Tompkins
Please open Telegram to view this post
VIEW IN TELEGRAM
๐7๐ฅ3โค1๐ค1
CHALLENGE
function* genSequence() {
const result = yield 'first';
console.log(result);
yield* [1, 2];
return 'done';
}
const gen = genSequence();
let next = gen.next('ignored');
console.log(next.value);
next = gen.next('second');
next = gen.next();
console.log(next.value);
next = gen.next();
console.log(next);
๐3โค2๐ฅ1
A surprisingly featureful control for letting users pick fonts from a range of system fonts, Google fonts, and custom fonts of your choice. You can play with a code demo here or go to the GitHub repo.
Zygomatic
Please open Telegram to view this post
VIEW IN TELEGRAM
โค3๐2๐ฅ1