小编Tat*_*Hui的帖子

在Javascript对象中var vs this

我正在为node.js开发一个web框架.这是代码;

function Router(request, response) {
        this.routes = {};

        var parse = require('url').parse;

        var path = parse(request.url).pathname,
            reqRoutes = this.routes[request.method],
            reqRoutesLen = reqRoutes.length;

        ..... // more code

};
Run Code Online (Sandbox Code Playgroud)

我应该将所有var更改为此,如下所示:

function Router(request, response) {
        this.routes = {};

        this.parse = require('url').parse;

        this.path = this.parse(request.url).pathname;
        this.reqRoutes = this.routes[request.method];
        this.reqRoutesLen = this.reqRoutes.length;

        ..... // more code

};
Run Code Online (Sandbox Code Playgroud)

任何意见?

javascript node.js

8
推荐指数
1
解决办法
2411
查看次数

Erlang和Antlr

是否可以为Erlang编写Antlr代码生成目标?

erlang parsing code-generation antlr

5
推荐指数
1
解决办法
1260
查看次数

标签 统计

antlr ×1

code-generation ×1

erlang ×1

javascript ×1

node.js ×1

parsing ×1