Why is shrinking Safari breaking existing code?

Firefox has no problem

var logger = window.console.log, // breaks Safari but not Firefox 

but Safari gives Type Error the first thing I'm trying to use logger() . Pay attention to the snippet below.

I went ahead and replaced all my logger () with window.console.log () to get rid of the error.

I don’t understand why Safari does not like it and why he calls it a type error.

Mistake

TypeError: enter error

Excerpt

 /*log ** ** ** */ NS.log = function (arg) { if (window.console) { var logger = window.console.log, // breaks Safari but not Firefox str1 = Object.prototype.toString.call(arg); // ... snip 
+1
javascript safari
source share
1 answer

This should work:

 var logger = window.console.log.bind(window.console) 
+4
source share

All Articles