Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(function () {
function Animal() {}
Object.defineProperties(Animal.prototype, {
noise: {
configurable: false,
enumerable: false,
value: null,
writable: false
}
});
Animal.prototype.makeNoise = function () {
throw new Error('You must override this method.');
};
function Dog() {
Animal.call(this);
}
Dog.prototype = Object.create(Animal.prototype);
Object.defineProperties(Dog.prototype, {
noise: {
configurable: false,
enumerable: false,
value: 'woof',
writable: false
}
});
Dog.prototype.constructor = Dog;
Dog.prototype.makeNoise = function () {
console.log(this.noise + '!');
};
var snoopy = new Dog();
if (snoopy instanceof Animal) {
console.log('snoopy is an instance of Animal.');
}
if (snoopy instanceof Dog) {
console.log('snoopy is an instance of Dog.');
}
snoopy.makeNoise();
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.