4 ms·
Don't use that in prod, because it doesn't work in IE and it will cause your js to stop working. In IE the 'console' object doesn't even exist if the developer
by tajen 12y ago
Don't use that in prod, because it doesn't work in IE and it will cause your js to stop working.
In IE the 'console' object doesn't even exist if the developer tools aren't displayed, so if you use "console.log" in your program, your js will just throw an NPE.
Note that if you try closing the Developer Tools, 'console' is still declared for this page and all descendant pages. To test 'console.log' you need to avoid opening the devtools and open a new tabs.
- cleverjake 12y agothat hasn't been the case since IE 9
- tajen 12y agoThis person is reporting it for IE10, do you have more insights? Do you think his IE was in compatibility mode? http://stackoverflow.com/questions/18480948/ie-10-debug-console-f12-changes-behavior http://stackoverflow.com/questions/18480948/ie-10-debug-cons...
- cleverjake 12y agoyep. compat mode.
- deanclatworthy 12y agoThe simple solution is to polyfill: https://github.com/paulmillr/console-polyfill https://github.com/paulmillr/console-polyfill
- ux-app 12y agoAnother solution is to remove all debug commands as part of your build/deploy process.
- rmchugh 12y agotoo right, extremely annoying bug, because when you open the dev tools to debug it, it starts working again!
- ahoge 12y ago> Don't use that in prod A linter will catch this.
- Encosia 12y agoI don't remember when exactly, but they fixed that at some point. I just ran this simple test in IE (without ever opening the dev tools) and got the alert: http://jsbin.com/hodavocuwu/1/edit http://jsbin.com/hodavocuwu/1/edit