There is a problem with this approach. Let's say somehow there is a problem in your production. But you can't reproduce that in your dev environment. A simpler way to not show console.log() output is to assign an empty function in your index/main JS file. I work with angular mainly. So, inside the main.ts file, I check which env it is and assign the empty function if it's a prod build.
console.log = () => {};
This way your console.log remains in your code but does nothing. If you want to debug, just do the following in the windows' devtool.
console.log = console.info
It will print the logs correctly.