Skip to main content
deleted 5 characters in body; edited tags
Source Link

Rather a technical question concerning javascriptJavaScript events:

Why does

window.onmousewheel = console.log; 

throw an Uncaught TypeError: Illegal invocation, while

window.onmousewheel = function (e) {console.log(e); }; 

works just as expected and prints the event as string? Why is the console.log, when assigned to window.onmousewheel, not just called with one parameter like the lambda expression?

Simon

Rather a technical question concerning javascript events:

Why does

window.onmousewheel = console.log; 

throw an Uncaught TypeError: Illegal invocation, while

window.onmousewheel = function (e) {console.log(e); }; 

works just as expected and prints the event as string? Why is the console.log, when assigned to window.onmousewheel, not just called with one parameter like the lambda expression?

Simon

Rather a technical question concerning JavaScript events:

Why does

window.onmousewheel = console.log; 

throw an Uncaught TypeError: Illegal invocation, while

window.onmousewheel = function (e) {console.log(e); }; 

works just as expected and prints the event as string? Why is the console.log, when assigned to window.onmousewheel, not just called with one parameter like the lambda expression?

Post Closed as "Duplicate" by Naftali, Paul S., Mani, Robby Pond, Blitz
Source Link
Simon
  • 59
  • 1
  • 5

Events with native vs. lambda functions

Rather a technical question concerning javascript events:

Why does

window.onmousewheel = console.log; 

throw an Uncaught TypeError: Illegal invocation, while

window.onmousewheel = function (e) {console.log(e); }; 

works just as expected and prints the event as string? Why is the console.log, when assigned to window.onmousewheel, not just called with one parameter like the lambda expression?

Simon