小编Avn*_*rSo的帖子

命名约定以区分节点JS中的模块/实例/方法变量

假设我有一些像这样的代码:

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"),但我仍然坚持功能和模块变量之间的差异.

是否存在区分这些的命名约定?

javascript naming naming-conventions node.js

4
推荐指数
1
解决办法
2061
查看次数

标签 统计

javascript ×1

naming ×1

naming-conventions ×1

node.js ×1