Contents
Are console errors bad?
It will cause Javascript errors, terminating the execution of the block of Javascript containing the error. If you use any methods other than log , you would need to stub out those as well.
Does console error throw an error?
throw raises an exception in the current code block and causes it to exit, or to flow to next catch statement if raised in a try block. console. error just prints out a red message to the browser developer tools javascript console and does not cause any changes of the execution flow.
Should you remove console log?
Generally yes, its not a great idea to expose log messages in your production code. Ideally, you should remove such log messages with a build script before deployment; but many (most) people do not use a build process (including me).
Is it normal to use console.log a lot?
If you are like me, then it is only normal you use console.log (…) a lot and forget to remove them (at least not all) from your codes. Now, imagine you visiting a website and seeing a bunch of logged data in your browser’s console, apart from it being messy LOL… it gingers you to start looking for what isn’t lost : )
Is the ” console.log ( ) ” call a bad idea?
Is this a bad idea? It will cause Javascript errors, terminating the execution of the block of Javascript containing the error. You could, however, define a dummy function that’s a no-op when Firebug is not active: If you use any methods other than log, you would need to stub out those as well.
How to deactivate console.log on production server?
Then a check is put in place through a conditional statement to check if your app is on the production server (as set by you), if that is true, it overwrites the console.log function and sets it to a redundant and empty function. Thus, invalidating every usage of the function in codes below it.
When to overwrite console.log ( production ) function?
Now, within your page before the importation of your custom js file, you should overwrite the console.log (…) function if the APP_ENV is set to production. Take a look at the snippet below. You must be angry at me for taking you through a long read just to show you the magic of an equal to sign.