<span id="test">a</span> <script> const a = { desc: 'tag', attr: 'href' } const obj = {a} const val = test.innerText alert(val) alert((obj[val] == a) ? true : false) </script>