ES6语法

        class Person {
            constructor(name) {
                this.name = name
            }
            hello() {
                console.log('Hello, my name is ' + this.name + '.');
            }
        }
        var xiaoMing = new Person('xiaoMing');
        xiaoMing.hello() // Hello, my name is xiaoMing.
posted @ 2020-09-04 09:40  学到秃顶  阅读(67)  评论(0)    收藏  举报