I am having some issues in my production code and I want to be able to send a flag to enable/disable JS logging, so I want to write my own logging function.
I want to use something like function log(){...}. When I looked up reserved words in JS I didn’t see
log listed, but I do see it listed in the w3schools docs as a math function.
Is it okay to use log() as a function name in production code for IE 7+, Chrome, and FF?
Yes, it is absolutely fine. The maths
logfunction is a function on theMathobject, so will not collide with your implementation.If you are confused by this sort of thing, look into JavaScript ‘namespaces’
How do I declare a namespace in JavaScript?