js构造对象 js深入理解构造函数和原型对象

https://www.cnblogs.com/thonrt/p/5900510.html

function Person(name,age){
     this.name = name;    
     this.age = age;   
     this.sayHello = function(){   
         console.log(this.name +"say hello");
    }
}

var boy = new Person("bella",23);    
boy.sayHello(); // bella say hello

 

//----------------------------------------------
 function ZtreeNode(id, pId, name) {//定义ztree的节点类
    this.id = id;
    this.pId = pId;
    this.name = name;
}    
var childZNode = new ZtreeNode(100,parentOrgId, '子节点0'); //构造子节点

你可能感兴趣的:(js)