Can you clarify why boolean is used while adding objects to the WeakMaps in the code below. I understand set takes two(key and value) arguments. The boolean values gets printed in the console as well…that is my doubt…
Thanks in Advance.
const book1 = { title: 'Pride and Prejudice', author: 'Jane Austen' };
const book2 = { title: 'The Catcher in the Rye', author: 'J.D. Salinger' };
const book3 = { title: 'Gulliver\'s Travels', author: 'Jonathan Swift' };
const library = new WeakMap();
library.set(book1, true);
library.set(book2, false);
library.set(book3, true);
console.log(library);
WeakMap {Object {title: 'Pride and Prejudice', author: 'Jane Austen'} => true, Object {title: 'The Catcher in the Rye', author: 'J.D. Salinger'} => false, Object {title: 'Gulliver\'s Travels', author: 'Jonathan Swift'} => true}