What is the output?
Anonymous Quiz
31%
['SARAH', 28, 'BOSTON']
43%
['NAME', 56, 'CITY']
18%
[undefined, 56, undefined]
7%
['NAME', 'CITY', 56]
❤4
It’s not often we see a library with such a funny demo on the homepage (it involves cats and laser pointers!) Navcat is a pathfinding library, aimed at games and simulations, for enabling objects to route through 3D space. There are numerous other interesting demos too. GitHub repo.
Isaac Mason
Please open Telegram to view this post
VIEW IN TELEGRAM
❤8🔥2👍1
CHALLENGE
const numbers = [1, 2, 3, 4, 5];
const result = numbers
.filter(n => n % 2 === 0)
.map(n => n * 2)
.reduce((acc, n) => acc + n, 0);
const original = numbers.slice();
original.reverse();
const flattened = [[1, 2], [3], [4, 5]].flat();
const found = flattened.find(n => n > 3);
console.log(result);
console.log(original.length);
console.log(found);
❤2
👍8❤2🔥1
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4👍2🔥1
CHALLENGE
try {
const obj = null;
obj.property = 'value';
} catch (e) {
console.log(e.name);
}
try {
undeclaredVariable;
} catch (e) {
console.log(e.name);
}
try {
JSON.parse('invalid json');
} catch (e) {
console.log(e.name);
}❤2
CHALLENGE
const source = {
value: 1,
subscribers: new Set(),
subscribe(fn) {
this.subscribers.add(fn);
return () => this.subscribers.delete(fn);
},
next(newValue) {
this.value = newValue;
this.subscribers.forEach(fn => fn(this.value));
}
};
const mapped = {
value: undefined,
source,
transform: x => x * 2,
init() {
this.source.subscribe(val => {
this.value = this.transform(val);
console.log(`Mapped: ${this.value}`);
});
}
};
mapped.init();
source.next(3);
source.next(5);
console.log(`Final: ${mapped.value}`);
source.next(2);❤4
What is the output?
Anonymous Quiz
24%
Mapped: 6 Mapped: 10 Mapped: 4 Final: 10
32%
Final: 10 Mapped: 4
32%
Mapped: 6 Mapped: 10 Final: 10 Mapped: 4
12%
Mapped: 6 Final: 10 Mapped: 10 Mapped: 4
❤3👍2🔥2
How is this possible?
Because Apple forgot to disable sourcemaps in production on the App Store website 🙃
Please open Telegram to view this post
VIEW IN TELEGRAM
🤣12❤8🔥3
CHALLENGE
const target = { name: 'John', age: 30 };
const handler = {
get(obj, prop) {
if (prop in obj) {
return `[${obj[prop]}]`;
}
return `missing: ${prop}`;
},
set(obj, prop, value) {
obj[prop] = value.toUpperCase();
return true;
}
};
const proxy = new Proxy(target, handler);
proxy.city = 'paris';
console.log(proxy.name);
console.log(proxy.city);
console.log(proxy.country);❤3👍3🔥1
What is the output?
Anonymous Quiz
26%
John PARIS undefined
28%
[John] [PARIS] undefined
20%
[John] [paris] missing: country
26%
[John] [PARIS] missing: country
JavaScript
They deleted the repo, but you can simply use wayback 😆
GitHub
GitHub - rxliuli/apps.apple.com: App Store web version
App Store web version. Contribute to rxliuli/apps.apple.com development by creating an account on GitHub.
❤5
CHALLENGE
const user = {
profile: {
settings: {
theme: 'dark'
}
}
};
const getTheme = (obj) => obj?.profile?.settings?.theme ?? 'light';
const getLanguage = (obj) => obj?.profile?.settings?.language ?? 'en';
const getNotifications = (obj) => obj?.profile?.notifications?.enabled ?? true;
console.log(getTheme(user));
console.log(getLanguage(user));
console.log(getNotifications(user));
console.log(getTheme(null));❤1
What is the output?
Anonymous Quiz
25%
dark, en, true, undefined
51%
dark, en, true, light
18%
dark, undefined, true, undefined
6%
dark, en, undefined, light
❤1🔥1