understanding John's class inheritance
hey guys i was just going to john R's post
here and he talks of a pattern he found that looks like below :
- var Person = Class.extend({
- init: function(isDancing){
- this.dancing = isDancing;
- },
- dance: function(){
- return this.dancing;
- }
- });
-
- var Ninja = Person.extend({
- init: function(){
- this._super( false );
- },
- dance: function(){
- // Call the inherited version of dance()
- return this._super();
- },
- swingSword: function(){
- return true;
- }
- });
-
- var p = new Person(true);
- p.dance(); // => true
-
- var n = new Ninja();
- n.dance(); // => false
- n.swingSword(); // => true
-
- // Should all be true
- p instanceof Person && p instanceof Class &&
- n instanceof Ninja && n instanceof Person && n instanceof Class
now i have a couple of questions about the above pattern , what is the following ::
i see this in the code
- this._super( false );
what is _super ???
also is the
extend used in here the Jquery extend function ? is the code relying on pure JS or Jquery ?
Thank you.