es6 class notes


 var House1 = function(){

    this.doors =3;

    this.windows = 10;

    this.color = "blue";

    }

class House {
    constructor() {
        this.name = "House";
        this.doors = 3;
        this.windows = 10;
        this.color = "blue";
        this.hello = function(){
            console.log("hello, I am a" + this.name);
            console.log("I have " + this.doors  + "color(s)");
            console.log("I am " + this.color);
        }
    }
}
var myhourse = new House()
console.log(myhourse.doors)
console.log(myhourse.windows)
console.log(myhourse.color)
myhourse.hello();

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325481539&siteId=291194637