node.js使用util实现简单继承

/**
 * Created by zzq on 2015/5/15.
 */
    var util = require('util');

    var Person = function(){
        var myD='1';
        this.name = "a",
        this.age = "18",
        this.adress = "地球"
    }

    var Student = function(){
        //获取父类的所有成员
        Person.call(this);
        this.No = "学号";
    }

    util.inherits(Student,Person);

var newStu = new Student();
console.log(newStu.name);

 

posted @ 2015-05-15 13:38  soft.push("zzq")  Views(136)  Comments(0)    收藏  举报