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 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 difference between `arguments` object and rest parameters `…args`? 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
What is tree shaking in JavaScript module bundlers and what syntax enables it? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const obj = { data: [1, 2, 3], double() { return this.data.map(function(n) { return n * this.multiplier; }); }, multiplier: 2 }; console.log(obj.double()); “` JavaScript ProfessionalMedium Try Now
What is an Immediately Invoked Function Expression (IIFE) and what problem did it solve before ES modules? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const a = {x: 1}; const b = {x: 1}; const m = new Map(); m.set(a, ‘first’); m.set(b, ‘second’); console.log(m.size); console.log(m.get({x:1})); “` JavaScript ProfessionalMedium Try Now
What is the difference between `Map.prototype.forEach()` and iterating with `for…of` on a Map? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const gen = function*() { const x = yield 1; const y = yield x + 2; return y; }; const g = gen(); console.log(g.next().value); console.log(g.next(10).value); console.log(g.next(20).value); “` JavaScript ProfessionalMedium Try Now
What does `Reflect.apply()` do and why prefer it over `Function.prototype.apply()`? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const p = new Promise(resolve => { console.log(‘A’); resolve(‘B’); console.log(‘C’); }); p.then(v => console.log(v)); console.log(‘D’); “` JavaScript ProfessionalMedium Try Now
What is the purpose of `Object.seal()` compared to `Object.freeze()`? JavaScript ProfessionalMedium Try Now
What is function composition in a practical JavaScript example? JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js class Counter { #count = 0; increment() { this.#count++; } get value() { return this.#count; } } const c = new Counter(); c.increment(); c.increment(); console.log(c.value); console.log(c.#count); “` JavaScript ProfessionalMedium Try Now
What is the output of the following? “`js const arr = [1, 2, 3]; arr[10] = 99; console.log(arr.length); console.log(arr[5]); “` JavaScript ProfessionalMedium Try Now