What is the output of the following code involving WeakRef? let obj = { name: ‘target’ }; const ref = new WeakRef(obj); obj = null; // GC may or may not have run console.log(ref.deref()?.name); JavaScript ProfessionalHard Try Now
What does the following generator code output? function* gen() { const x = yield 1; yield x + 10; } const g = gen(); console.log(g.next()); // A console.log(g.next(5)); // B JavaScript ProfessionalHard Try Now
What is the precise difference between Object.getOwnPropertyDescriptor and the in operator for checking property existence? JavaScript ProfessionalHard Try Now
What does the following code output and why? function foo() { return { bar: ‘baz’ }; } function foo2() { return { bar: ‘baz’ }; } console.log(foo(), foo2()); JavaScript ProfessionalHard Try Now
Which internal slot does the specification use to track whether a Promise has been resolved, and what prevents resolving a Promise twice? JavaScript ProfessionalHard Try Now
What is the output of the following code? const obj = {}; obj[Symbol.toPrimitive] = (hint) => hint === ‘number’ ? 42 : ‘hello’; console.log(+obj, `${obj}`, obj + ”); JavaScript ProfessionalHard Try Now
What does the following implement? function pipe(…fns) { return x => fns.reduce((v, f) => f(v), x); } JavaScript DeveloperMedium Try Now
What is the output of: console.log(+’3′, +true, +null, +undefined)? JavaScript DeveloperMedium Try Now
What does the following code output? const a = [1, 2, 3]; const b = [1, 2, 3]; console.log(a == b, a === b); 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 {a: x, b: y = 10} = {a: 1}; console.log(x, y); JavaScript DeveloperMedium Try Now