假设我有一些像这样的代码:
var moduleVar = "I belong to this module, you could also call me a static var";
var ClassName = function() {
var instanceVar = "I belong to this instance";
function someFunction(functionVar) {
var anotherFunctionVar = "I belong to this function";
return 1;
}
}
module.exports = ClassName;
Run Code Online (Sandbox Code Playgroud)
我一直在寻找节点的命名约定,但我还没有找到任何解决这个问题的方法.我喜欢用下划线为实例变量添加前缀(例如"_instanceVar"),但我仍然坚持功能和模块变量之间的差异.
是否存在区分这些的命名约定?