我想知道为什么像EmberJS这样的框架使用_super方法来调用扩展对象上被覆盖的方法,而不是(在我看来)更符合逻辑的this.super方法。
有什么特别的原因吗,比如super是javascript中的保留关键字?因此,您不能将变量或命名函数赋给名称super。分配给this.super的函数是匿名函数,对吗?
发布于 2014-08-30 18:10:04
_表示私有成员。您只能从类内部访问_super,而不能从外部访问。
发布于 2014-08-29 21:09:27
_super可用于区分可能已设置的其他功能。这可能是为了展示它的特殊之处,或者与其他变量的不同之处。也可能是为了显示它是私人的。
请参见:
When do you make an underscore in front of an instance variable?
How does an underscore in front of a variable in a cocoa objective-c class work?
Why do we use _ in variable names?
编辑:就像Barmar所说的(除了少得多的话),它是一种编码风格,没有别的。
https://stackoverflow.com/questions/25568800
复制相似问题