Что я делаю не так? получаю
indexPage.addScripts is not a functionclass Page {
constructor({ pageName, scriptNames, styleNames }) {
if (!pageName || typeof pageName != "string") {
throw new Error("Enter page name in config file!!!");
}
this.name = pageName;
this.scripts = scriptNames || [];
this.styles = styleNames || [];
return this.data();
}
addScripts(scripts) {
if (Array.isArray(scripts)) {
this.scripts = this.scripts.concat(scripts);
} else {
this.scripts.push(scripts.toString());
}
}
addStyles(styles) {
if (Array.isArray(styles)) {
this.styles = this.styles.concat(styles);
} else {
this.styles.push(styles.toString());
}
}
data() {
return {
name: this.name,
scripts: this.scripts,
styles: this.styles
};
}
}
let indexPage = new Page({
pageName: 'index',
scriptNames: [
'index',
'main'
],
styleNames: [
'frontpage'
]
});
indexPage.addScripts('geo');