I have just started writing my own JavaScript Framework (just for the learning experience), and have prefixed some private members with a _, like such:
var _isFireBugEnabled = function () { return (window.console && window.console.firebug); };
When I ran my code against Crockford’s JSLint (as always), with Recommended Options on, I was told about not using a _ as an identifier.
My question is, Why does JSLint warn me as regards not using a _ as an identifier?
Are there some side effects or implications I am missing here?
PS. As far as I could scan just now, this is not documented in the book
The reason is that Douglas Crockford hates about 78% of Javascript*. Many people think he’s a bit strict, and in fact many libraries do use leading underscores in production code. I don’t see much wrong with it. There are no side effects.
Additionally, the ‘$’, not the underscore, was the symbol set aside for ‘system’ code by the ECMA spec.
*Note: I’m being facetious. He really only hates about half, and he typically has good reason. I’d disagree with Crockford here, but he’s usually very right.