标签:prot bsp obj on() second func name nbsp 基础
Node 创建对象的方法
1.
var User = new Object();
User.first = "Brad";
User.second = "Balyley";
User.getName = function(){ return this.first + " " + this.second;}
2.
var User = {
first:‘Brad‘,
second:‘Balyley‘,
getName:function(){return this.first + " " + this.second}
}
3.
function User(first,second){
this.first = first;
this.second = second;
this.getName = function(){this.first + " " + this.second;}
}
4.
funciton User(first,second)
{
this.first = first;
this.second = second;
}
User.prototype = {
getName:function(){
return this.first + " " + this.second;
}
}
标签:prot bsp obj on() second func name nbsp 基础
原文地址:https://www.cnblogs.com/ninjakim/p/9218418.html