Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Use regular function with DOM event listeners, when using "this" keyword

const link = document.querySelector('#link')
link.addEventListener('click', () => {
  // this === window
})

const link = document.querySelector('#link')
link.addEventListener('click', function() {
  // this === link
})
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Use #regular #function #DOM #event #keyword
ADD COMMENT
Topic
Name
4+1 =