Js怎么实现一个类,怎么实例化这个类
1.functin demo(x){alert(x)}。
2.js是一门弱类型语言,与c++和java语言不通,并没有强调类。实际应用中用function实现它的内容。
function People () {
this.name = “Yorhom”;
this.getName = function () {
return this.name
};
}
var yorhom = new People();
// “Yorhom”
alert(yorhom.getName())
3.类的实现可通过对原型操作来实现