0

I am new to Javascript and was reading an article about the Javascript events and found that in the article the author used '()=>{}' instead of 'function(){}' for event handlers. So I want to know what is that and what is the difference between these two ?

//What is the difference between these two ?
element.onclick = ()=>{
    alert("Ok");
};

element.onclick = function(){
    alert("Ok");
};
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

0 Answers0