Is there a way to log to console without breaking code under IE?

前端 未结 6 553
后悔当初
后悔当初 2021-02-05 18:50

I\'m trying to use console.log to put some logging into the javascript side of my program. I noticed, though, that unless the dev console is open in IE, JS basically stops worki

6条回答
  •  青春惊慌失措
    2021-02-05 19:55

    You can create a fake console:

    if (typeof console === "undefined")
        console = { log: function() { } };
    

提交回复
热议问题