скорее технический вопрос относительно событий JavaScript:События с родной против функций лямбда
Почему
window.onmousewheel = console.log;
бросить Uncaught TypeError: Illegal invocation
, в то время как
window.onmousewheel = function (e) {console.log(e); };
работает так же, как ожидается, и печатает событие как строка? Почему console.log
, если присвоено window.onmousewheel
, не просто вызвано одним параметром, как выражение лямбда?
Саймон
[Chrome не распознает console.log ...] (HTTP: // StackOverflow .com/questions/9612398/chrome-doesnt-узнайте-console-log-when-its-called-log) ... http://stackoverflow.com/questions/8904782/uncaught-typeerror-illegal-invocation-in- javascript ... http://stackoverflow.com/questions/16615781/why-is-console-log-illegaly-invocated-as-a-function-parameter ... http://stackoverflow.com/questions/12944987/ abbreviating-console-log-in-javascript ... http://stackoverflow.com/questions/5133649/alias-to-chrome-console-log ... http://stackoverflow.com/questions/5456709/create-shortcut-to-console-log-in-chrome –
http://stackoverflow.com/questions/5538972/console-log-apply-not-working-in-ie9 –
Попробуйте 'window.onmousewheel = console.log .bind (консоль); '. –