What is the difference between .addEventListener ().onclick = function() in JS?

What is the difference between .addEventListener ().onclick = function() in JS?
and
Why is now used more often .addEventListener()

Maybe it's a different version?
Thank you all for the answers!
June 8th 19 at 17:02
3 answers
June 8th 19 at 17:04
Solution
addEventListener adds tracking of any eventthat indicates a onclick - only clicks. So what to use depends on the task.

In addition, the second method allows you to hang only one event handler (the following will peristerite previous), while the first - indefinitely.
June 8th 19 at 17:06
.onclick sometimes it is easier for a programmer - no need to call the constructor, already have a property

compare the pseudocode:

button.onclick = functionrelated

button.funkcijata( tiponline, functionrelated )
June 8th 19 at 17:08
Else addEventListener you can control the display of events

Find more questions by tags JavaScript