<span id="el1">first element</span>
<span id="el2">second element</span>
<script>
const someObj = {
[document.getElementById('el1')]: 'some value'
};
console.log(someObj[document.getElementById('el1')]);
// 'some value'
</script>
<span id="thing" class="thing">a thing.</span>
<script>
const myWeakMap = new WeakMap();
// Set a value to a specific node reference.
myWeakMap.set(document.getElementById('thing'), 'some value');
// Access that value by passing the same reference.
console.log(myWeakMap.get(document.querySelector('.thing')); // 'some value'
</script>