I'm wondering why a framework like EmberJS uses the _super
method for calling the overridden method on the extended object instead of the (in my opinion) more logical this.super
.
Is there a specific reason for this, for instance that super
is a reserved keyword in javascript? So you cannot assign variables or named functions to the name super
. The function assigned to this.super
is an anonymous function right?
I'm wondering why a framework like EmberJS uses the _super
method for calling the overridden method on the extended object instead of the (in my opinion) more logical this.super
.
Is there a specific reason for this, for instance that super
is a reserved keyword in javascript? So you cannot assign variables or named functions to the name super
. The function assigned to this.super
is an anonymous function right?
- 1 It's just coding style. – Barmar Commented Aug 29, 2014 at 13:01
-
2
super
has been a Future Reserved Word in all previous editions of ECMAScript. The 5th edition did permit the user of reserved words as (unquoted) properties. But, IE8 for example might throw a syntax error as it was based on the 3rd edition. – Jonathan Lonowski Commented Aug 29, 2014 at 13:13
2 Answers
Reset to default 3_
indicates a private member. You're only supposed to access _super
from inside the class, never from the outside.
_super may be used to differenate it between other functions that may have been set. This could have been to show how it's special, or different than other variables. Or it could be to show it's private.
See:
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?
EDIT: Like Barmar said (except in much less words) it's a coding style, nothing else.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744915433a4600803.html
评论列表(0条)