Answer the question
In order to leave comments, you need to log in
What is the correct way to pass arguments to a class constructor?
There is such a class:
class Skill {
constructor({
typeId,
name,
description,
groupId,
primaryAttribute, // 180
secondaryAttribute, // 181
skillTimeConstant, // 275
requiredSkill1, // 182
requiredSkill1Level, // 277
requiredSkill2, // 183
requiredSkill2Level, // 278
requiredSkill3, // 184
requiredSkill3Level, // 279
}) {
this.typeId = typeId;
this.name = name;
this.description = description;
this.groupId = groupId;
this.primaryAttribute = primaryAttribute; // 180
this.secondaryAttribute = secondaryAttribute; // 181
this.skillTimeConstant = skillTimeConstant; // 275
this.requiredSkill1 = requiredSkill1; // 182
this.requiredSkill1Level = requiredSkill1Level; // 277
this.requiredSkill2 = requiredSkill2; // 183
this.requiredSkill2Level = requiredSkill2Level; // 278
this.requiredSkill3 = requiredSkill3; // 184
this.requiredSkill3Level = requiredSkill3Level; // 279
}
}
Answer the question
In order to leave comments, you need to log in
const options = {
typeId,
name,
description,
groupId,
primaryAttribute, // 180
secondaryAttribute, // 181
skillTimeConstant, // 275
requiredSkill1, // 182
requiredSkill1Level, // 277
requiredSkill2, // 183
requiredSkill2Level, // 278
requiredSkill3, // 184
requiredSkill3Level, // 279
};
class Skill {
constructor(options) {
Object.assign(this, options);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question