我有3个代码:
var control = new Control(); function Control() { this.doSomethingElse = function() {...} this.doSomething = function () { control.doSomethingElse(); } }
要么
var control = new Control(); function Control() { var self = this; this.doSomethingElse = function() {...} this.doSomething = function () { self.doSomethingElse(); } }
要么
var control = Control(); function Control() { var self = this; this.doSomethingElse = function() {...} this.doSomething = function () { self.doSomethingElse(); } return self; }
重要提示:该函数是一个控制器,只声明一次.然后我在我的代码中到处使用"控制"...
我想知道control.doSomethingElse()是否很慢?
最后,在这些例子中做什么和/或最快的代码是什么?
谢谢 !