What is the output?
Anonymous Quiz
24%
Mapped: 6 Mapped: 10 Mapped: 4 Final: 10
31%
Final: 10 Mapped: 4
34%
Mapped: 6 Mapped: 10 Final: 10 Mapped: 4
11%
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);❤6👍3🔥1
What is the output?
Anonymous Quiz
24%
John PARIS undefined
28%
[John] [PARIS] undefined
20%
[John] [paris] missing: country
28%
[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.
❤6
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));❤2
What is the output?
Anonymous Quiz
24%
dark, en, true, undefined
46%
dark, en, true, light
21%
dark, undefined, true, undefined
9%
dark, en, undefined, light
❤3🔥2🤣1
CHALLENGE
const moduleMap = new Map();
async function loadModule(name) {
if (moduleMap.has(name)) {
return moduleMap.get(name);
}
const module = await Promise.resolve({
default: () => `Module ${name} loaded`,
version: '1.0.0'
});
moduleMap.set(name, module);
return module;
}
loadModule('auth').then(m => console.log(m.default()));
loadModule('auth').then(m => console.log(m.version));
loadModule('db').then(m => console.log(m.default()));
❤3👍1
CHALLENGE
function createCounter() {
let count = 0;
return {
increment: () => ++count,
decrement: () => --count,
getValue: () => count
};
}
const counter1 = createCounter();
const counter2 = createCounter();
counter1.increment();
counter1.increment();
counter2.increment();
console.log(counter1.getValue(), counter2.getValue());
counter1.decrement();
console.log(counter1.getValue(), counter2.getValue());❤5👍2🤩1
❤8🔥3
CHALLENGE
const wm = new WeakMap();
const obj1 = { name: 'first' };
const obj2 = { name: 'second' };
const obj3 = obj1;
wm.set(obj1, 'value1');
wm.set(obj2, 'value2');
wm.set(obj3, 'value3');
console.log(wm.get(obj1));
console.log(wm.get(obj2));
console.log(wm.get(obj3));
console.log(wm.has(obj1));
console.log(wm.size);
❤3👍1
What is the output?
Anonymous Quiz
21%
value3 value2 value3 true 3
32%
value3 value2 value3 true undefined
33%
value1 value2 value1 true undefined
15%
value1 value2 value3 true 2
👍5🔥3
CHALLENGE
class CustomError extends Error {
constructor(message) {
super(message);
this.name = 'CustomError';
}
}
try {
throw new CustomError('Something went wrong');
} catch (e) {
console.log(e instanceof Error);
console.log(e instanceof CustomError);
console.log(e.constructor.name);
console.log(e.name);
}What is the output?
Anonymous Quiz
23%
true, false, Error, CustomError
32%
false, true, CustomError, Error
42%
true, true, CustomError, CustomError
3%
true, true, Error, Error
👍5❤2🔥2
CHALLENGE
class EventEmitter {
constructor() {
this.events = {};
}
on(event, callback) {
this.events[event] = this.events[event] || [];
this.events[event].push(callback);
return this;
}
emit(event, data) {
if (this.events[event]) {
this.events[event].forEach(cb => cb(data));
}
return this;
}
}
class Logger {
log(msg) { console.log(`[LOG]: ${msg}`); }
}
class DataProcessor {
constructor(emitter, logger) {
this.emitter = emitter;
this.logger = logger;
this.emitter.on('process', (data) => {
this.logger.log(data.toUpperCase());
});
}
process(data) {
this.emitter.emit('process', data);
}
}
const emitter = new EventEmitter();
const logger = new Logger();
const processor = new DataProcessor(emitter, logger);
processor.process('hello world');
emitter.emit('process', 'composition rocks');👍3❤1
Did you know the Node.js project maintains a page about security best practices organized around how to mitigate ten of the most significant vectors? Topics include networking weaknesses, timing attacks, supply chain attacks, and the monkey patching of intrinsics.
Node Documentation
Please open Telegram to view this post
VIEW IN TELEGRAM
❤3🔥1