Answer the question
In order to leave comments, you need to log in
How to approach the implementation of this mechanism?
Good afternoon,
There is an array of objects created using a similar constructor:
function Squad(options)
{
this.name=options.name || 'Unnamed';
this.description=options.description || "This is one of unidentified warrior";
this.commander=options.commander || false;
this.cost=options.cost || 0;
this.rules=options.rules || null;
this.weaponSkill=options.weaponSkill || 0;
this.ballisticSkill=options.ballisticSkill || 0;
this.strength=options.strength || 0;
this.toughness=options.toughness || 0;
this.initiative=options.initiative || 0;
this.speed=options.speed || 0;
this.wound=options.wound || 0;
this.attackCount=options.attackCount || 0;
this.leadership=options.leadership || 0;
this.armorSave=options.armorSave || 0;
this.invulnerable=options.invulnerable|| 7;
this.availableWeapon=options.availableWeapon || null;
this.meleeWeapon=null;
this.rangeWeapon=null;
}
Answer the question
In order to leave comments, you need to log in
Very similar to the backpack problem: https://en.wikipedia.org/wiki/%D0%97%D0%B0%D0%B4%D...
The delete operator exists to remove the properties of an object; your example only works because you don't use the keywords (var, let) to declare the test variable , and so it becomes a property of the window object .
"delete deletes a variable" is of course not true, delete does not delete variables, except that by variables you mean such cases: variables declared without keywords, that is, window properties .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question