What is the output of the following code? const handler = { set(target, prop, value) { if (typeof value !== ‘number’) throw new TypeError(‘Numbers only’); return Reflect.set(target, prop, value); } }; const numObj = new Proxy({}, handler); numObj.a = 5; numObj.b = ‘hi’; console.log(numObj.a); JavaScript ProfessionalHard Try Now
What is the purpose of the Error.cause property introduced in ES2022? JavaScript ProfessionalHard Try Now
What is the key behavioral difference between a regular function and an async function when they throw synchronously inside their body? JavaScript ProfessionalHard Try Now
What does the following code output? const a = { x: 1 }; const b = Object.create(a); b.y = 2; console.log(Object.keys(b), Object.getOwnPropertyNames(b), ‘x’ in b); JavaScript ProfessionalHard Try Now
What is the purpose of Symbol.species and why is it controversial? JavaScript ProfessionalHard Try Now
What is the output of the following code? const map = new Map([[1, ‘a’], [2, ‘b’], [3, ‘c’]]); const obj = Object.fromEntries(map); console.log(typeof Object.keys(obj)[0], Object.keys(obj)[0]); JavaScript ProfessionalHard Try Now
What is the output of the following code? const log = console.log.bind(console); [1, 2, 3].forEach(log); JavaScript ProfessionalHard Try Now
What distinguishes the module record’s [[RequestedModules]] from [[ImportedBindings]] in the ECMAScript module linking algorithm? JavaScript ProfessionalHard Try Now
What is the output of the following code? const obj = { [Symbol.toPrimitive](hint) { if (hint === ‘default’) return ‘default’; return 42; } }; console.log(obj == ‘default’); JavaScript ProfessionalHard Try Now
What does the following code output? function test(a, b = a * 2, c = a + b) { return [a, b, c]; } console.log(test(3)); JavaScript ProfessionalHard Try Now
What is the Spectre vulnerability and how does it affect JavaScript’s SharedArrayBuffer availability? JavaScript ProfessionalHard Try Now
What is the output of the following code? const p = Promise.reject(new Error(‘fail’)); setTimeout(() => p.catch(e => console.log(e.message)), 0); JavaScript ProfessionalHard Try Now
What does the following Proxy demonstrate? const revocable = Proxy.revocable({}, { get: (t, k) => k }); console.log(revocable.proxy.foo); revocable.revoke(); console.log(revocable.proxy.bar); JavaScript ProfessionalHard Try Now
What is the key difference between Object.seal() and Object.freeze()? JavaScript ProfessionalHard Try Now
What does the following code demonstrate? const brand = Symbol(‘brand’); class MyArray extends Array { static [Symbol.hasInstance](instance) { return Array.isArray(instance); } } console.log([] instanceof MyArray); JavaScript ProfessionalHard Try Now
What does the following code output? function* fibonacci() { let [a, b] = [0, 1]; while (true) { yield a; [a, b] = [b, a + b]; } } const fib = fibonacci(); console.log([…Array(5)].map(() => fib.next().value)); JavaScript ProfessionalHard Try Now
What is the output of the following code? class Counter { #count = 0; increment() { this.#count++; } get value() { return this.#count; } } const c = new Counter(); c.increment(); console.log(c.value, c.#count); JavaScript ProfessionalHard Try Now