What is the difference between `Array.prototype.reduceRight()` and `reduce()`? JavaScript ProfessionalMedium Try Now
What is `Intl.Collator` used for and why is string comparison with `localeCompare()` important? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js class EventEmitter { #handlers = {}; on(event, handler) { (this.#handlers[event] ??= []).push(handler); } emit(event, data) { this.#handlers[event]?.forEach(h => h(data)); } } const ee = new EventEmitter(); ee.on(‘test’, v => console.log(v * 2)); ee.emit(‘test’, 5); ee.emit(‘missing’, 5); “` JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js async function* generate() { for (const n of [1, 2, 3]) { yield await Promise.resolve(n * 10); } } (async () => { const results = []; for await (const val of generate()) { results.push(val); } console.log(results); })(); “` JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const handler = { apply(target, thisArg, args) { return target.apply(thisArg, args) * 2; } }; const double = new Proxy(x => x + 1, handler); console.log(double(5)); “` JavaScript ProfessionalMedium Try Now
What is the purpose of `Object.defineProperty()` and when must you use it instead of direct assignment? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js let resolve; const p = new Promise(r => { resolve = r; }); p.then(v => console.log(‘resolved:’, v)); resolve(42); console.log(‘sync done’); “` JavaScript ProfessionalMedium Try Now
What is the difference between `Array.prototype.copyWithin()` and `Array.prototype.fill()`? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js function foo(a, b = a * 2, c = a + b) { return [a, b, c]; } console.log(foo(3)); “` JavaScript ProfessionalMedium Try Now
What is the `Temporal` proposal in JavaScript and what problem does it solve? JavaScript ProfessionalMedium Try Now
What is `WeakSet` in JavaScript and how does it differ from `Set`? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const obj = {}; obj.a = 1; Object.defineProperty(obj, ‘b’, {value: 2, enumerable: false}); const copy = {…obj}; console.log(copy); “` JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const promises = [1,2,3].map(n => new Promise(resolve => setTimeout(() => resolve(n * 2), n * 100)) ); Promise.all(promises).then(results => console.log(results)); “` JavaScript ProfessionalMedium Try Now
What is the purpose of `Object.getOwnPropertyDescriptor()` and when would you use it? JavaScript ProfessionalMedium Try Now
What is the difference between `arguments` object and rest parameters `…args`? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js function tag(strings, …values) { return strings.raw[0] + values[0]; } console.log(tag`HellonWorld ${42}`); “` JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const target = {}; const handler = { get(t, key) { return key in t ? t[key] : `Property ${key} not found`; } }; const proxy = new Proxy(target, handler); target.name = ‘Alice’; console.log(proxy.name); console.log(proxy.age); “` JavaScript ProfessionalMedium Try Now