What is the output of the following? “`js const a = { val: 1 }; const b = { val: 2 }; const weakSet = new WeakSet([a, b]); console.log(weakSet.has(a)); console.log(weakSet.size); “`
JavaScript DeveloperHard
JavaScript Developer — Hard
What is the output of the following? “`js const a = { val: 1 }; const b = { val: 2 }; const weakSet = new WeakSet([a, b]); console.log(weakSet.has(a)); console.log(weakSet.size); “`
Explanation
The output will be "true, undefined" because WeakSet does not have a "size" property. The "has" method will return true if the WeakSet contains the specified object.