Just a quick question about JavaScript inheritance:
Say we have a Person object:
function Person(name, age) {
this.name = name;
this.age = age;
}
Is there any significant difference between the following two snippets:
function Soldier(name, age, weapon) {
Person.call(this, name, age);
this.weapon = weapon;
}
... and
function Soldier(name, age, weapon) {
this.weapon = weapon;
}
Soldier.prototype = new Person();
Solder.prototype.attack = function () {
console.log("ATTACK!");
}
Also, when I write
Person.something
what does that do exactly?