" I'm working on WeakMap and WeakSet I'm trying to delete the object using null but still object is not deleted"
WeakMap:-
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);
book1 = null;
console.log(library);
WeakSet:-
let student1 = { name: 'James', age: 26, gender: 'male' };
let student2 = { name: 'Julia', age: 27, gender: 'female' };
let student3 = { name: 'Richard', age: 31, gender: 'male' };
let roster = new WeakSet([student1, student2, student3]);
console.log(roster);
student3 = null;
console.log(roster);
I expected to delete the object using "null" but still getting the null objects onto the data structure.