Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Using DOM Nodes As Keys

<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>
Source by macarthur.me #
 
PREVIOUS NEXT
Tagged: #Using #DOM #Nodes #As #Keys
ADD COMMENT
Topic
Name
1+6 =