Node.js:util.inherits 대상 특성 [원형]

2090 단어 node.js
/**

 * Created by Administrator on 2014/9/4.

 */

var util = require('util');

function Base() {

    this.name = ' ';

    this.base = '1992';

    this.sayHello = function() {

        console.error('Hello' + this.name);

    }

}



Base.prototype.showName = function() {

    console.log(this.name);

}



function Sub() {

    this.name = ' ';

    this.base = '1993';

}



util.inherits( Sub , Base );



var objBase = new Base();

var objSub  = new Sub();



objBase.showName();

objBase.sayHello();

console.error(objBase);



objSub.showName();/* showName Baes ,  */

//objSub.sayHello();/* sayHello Base  */

console.log(objSub);

좋은 웹페이지 즐겨찾기