承継:Inheritance

The global championship of intelligence and technology:                 http://roborace.com/

     Inheritance

My experiment with Inheritance in Javascript. I might not know what I am doing but

var ClassA = function() {
    this.name = "class A";
}

This “class” can be instantiated using the new keyword:

var a = new ClassA();
ClassA.prototype.print = function() {
    console.log(this.name);
}

var a = new ClassA();

a.print();

example:
var inheritsFrom = function (child, parent) {

 child.prototype = Object.create(parent.prototype); };

     Drone Racing

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s