Store values keyed by DOM nodes without Map or WeakMap
This Node Store ES5 variant is harder than a Map-based version because you have to track nodes without ES6 collections. Create a class called NodeStore that allows you to store values associated with DOM nodes. The class should provide the following methods:
Important: You cannot use Map or WeakMap in this problem.
Your solution should work in older JavaScript environments (like ES5), where such features are unavailable.
Hint: DOM nodes are mutable JavaScript objects. Can you use that to your advantage?
Example:
const node1 = document.createElement('p');
const node2 = document.createElement('p');
const store = new NodeStore();
store.set(node1, 1);
store.set(node2, 2);
console.log(store.get(node1)); // Expected output: 1
console.log(store.get(node2)); // Expected output: 2
This task tests your understanding of JavaScript classes, DOM manipulation, object property behavior, and memory-efficient design. It’s a practical scenario for frontend developers managing metadata tied to specific DOM elements.