Which approach correctly creates a deep copy of a plain JSON-serializable object in modern JavaScript? JavaScript DeveloperMedium Try Now
What is the output of the following? const {a: x, b: y = 10} = {a: 1}; console.log(x, y); JavaScript DeveloperMedium Try Now
What does the following code log? const obj = { a: 1 }; const copy = Object.assign({}, obj); copy.a = 99; console.log(obj.a); JavaScript DeveloperMedium Try Now
What does the following snippet demonstrate? const memoize = fn => { const cache = new Map(); return (…args) => { const key = JSON.stringify(args); if (cache.has(key)) return cache.get(key); const result = fn(…args); cache.set(key, result); return result; }; }; JavaScript DeveloperMedium Try Now
What is the output of the following? async function foo() { return 42; } console.log(foo()); JavaScript DeveloperMedium Try Now
What does the following code output? class Animal { constructor(name) { this.name = name; } speak() { return `${this.name} makes a noise.`; } } class Dog extends Animal { speak() { return `${this.name} barks.`; } } const d = new Dog(‘Rex’); console.log(d.speak()); JavaScript DeveloperMedium Try Now
What is the output of the following? const p = new Promise(resolve => resolve(1)); p.then(v => v * 2).then(v => console.log(v)); JavaScript DeveloperMedium Try Now
What does the following code output? console.log(‘a’); setTimeout(() => console.log(‘b’), 0); Promise.resolve().then(() => console.log(‘c’)); console.log(‘d’); JavaScript DeveloperMedium Try Now
What is the difference between call() and apply() when invoking a function? JavaScript DeveloperMedium Try Now