Objects

by imcrthy

JavaScript

console.clear();

// Protype method

var AnswerPrototype = {
    constructor: function constructor( value ) {
        this._val = value;
    },
    
    get: function get() {
        return this._val;
    }
};

var lifeAnswer = Object.create( AnswerPrototype );
lifeAnswer.constructor( 10 );

var dessertAnswer = Object.create( AnswerPrototype );
dessertAnswer.constructor( 20 );

// Inheritance

var FirmAnswerPrototype = Object.create( AnswerProtoypt );





// Contructor method

function Answer( value ) {
    this._val = value;
};

Answer.prototype = {
    get: function get() {
        return this._val;   
    }
};

// Inheritance

function FirmAnswer( value ) {
    Answer.call( this, value )
};

FirmAnswer.prototype = Object.create( Answer.prototype );
FirmAnswer.prototype.constructor = FirmAnswer;