js基础

1构造函数

function Student(name) {
    this.name = name;
    this.hello = function () {
        alert('Hello, ' + this.name + '!');
    }
}

//调用
var xiaoming = new Student('小明');
xiaoming.name; // '小明'
xiaoming.hello();

 

posted @ 2018-11-10 11:07  DevOps_QXW  阅读(74)  评论(0编辑  收藏  举报