Hard
How can you use WeakMap to manage private data in JavaScript objects?
1const privateData = new WeakMap();23class Person {4 constructor(name, age) {5 privateData.set(this, { name, age });6 }78 getName() {9 return privateData.get(this).name;10 }1112 getAge() {13 return privateData.get(this).age;14 }15}1617const alice = new Person('Alice', 30);18console.log(alice.getName());19console.log(alice.getAge());