<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>