Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5939147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:47:07+00:00 2026-05-22T15:47:07+00:00

I understand the difference between an addEventListener and the onclick property and know how

  • 0

I understand the difference between an addEventListener and the onclick property and know how to use both. I am wondering if there is a draw back to always using EventListener‘s instead of using the onclick property. The EventListener appears to be much more powerful than just using the onclick atleast when dynamically generating the HTML from javascript.

Is there a memory/cpu drawback or am I safe to only use EventListeners?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:47:08+00:00Added an answer on May 22, 2026 at 3:47 pm

    This probably isn’t the direction you were going in, but there are a few instances where you would be unable to remove an event listener.

    Event handlers are completely public, and can be modified (to a certain extent) by anyone:

    // You do this
    myLink.onclick = function () {
        alert('hello, world');
    };
    
    // Another developer who hates you because
    // he thinks that you're hitting on his girlfriend
    // but you're not, you're just friends, but
    // he's jealous so he doesn't understand
    // does this
    myLink.onclick = function () {
        alert('muahahahaha');
    };
    
    // Someone else could even get rid of
    // the handler entirely:
    myLink.onclick = null;
    

    But there is no publically accessible list of event listeners. The only way to remove an event listener is if you still have access to the original function:

    myLink.addEventListener('click', function () {
        alert('hello, world');
    }, false);
    

    There is now no way to remove that event listener. You gave it an anonymous function, so even you wouldn’t be able to remove it if you wanted to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand the difference between a process and a thread. And I know the
I don’t understand the difference between let mapleader=, and let g:mapleader=, . I know
I'm using for the firs time optional arguments but I cannot understand difference between
I understand the difference between real,user and sys when you use the time command
I'm trying to understand the difference between rows created using the following methods: newTable.Rows.Add(array);
I understand the difference between Live and Bind but when should I use use
I'd like to understand the difference between redirecting and rewriting a URL using .htaccess.
I'm trying to understand the difference between using a UINavigationController inside a Nib (via
I couldn't understand the difference between SELECT DATEDIFF(D,'07/09/1978',GETDATE()) SELECT DATEDIFF(DD,'07/09/1978',GETDATE()) Both are giving the
I'm struggling to understand the difference between shell_exec() and exec() ... I've always used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.