All quizzesHard
Expert Mastery — Series 2
Preview — 3 of 10 questions
What is the output?
javascript
const handler = {
get(target, key) {
return key in target ? target[key] : 37;
},
};
const p = new Proxy({}, handler);
p.a = 1;
console.log(p.a, p.b);A1 undefined
B1 37
Cundefined 37
DTypeError
Which statement about WeakRef is correct?
AA WeakRef prevents garbage collection of the referenced object.
BweakRef.deref() always returns the original object.
CA WeakRef allows the GC to collect the object; deref() returns undefined after collection.
DWeakRef is equivalent to a regular object reference.
What does the following print?
javascript
function* gen() {
const x = yield 1;
const y = yield x + 10;
return x + y;
}
const g = gen();
console.log(g.next());
console.log(g.next(5));
console.log(g.next(3));A{value:1,done:false} / {value:15,done:false} / {value:8,done:true}
B{value:1,done:false} / {value:10,done:false} / {value:5,done:true}
C{value:1,done:false} / {value:15,done:false} / {value:5,done:true}
D{value:undefined,done:false} / {value:15,done:false} / {value:8,done:true}
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.