Reputation: 475
This is the first time I'm trying to work with classes (or the Javascript equivalent to classes).
With the following code I get the error: Missing ( before function parameters. in Zeile 8
Do I have some error in the syntax here? Or is it not possible to pass variables to a "class method"?
function tagConstructor() {
this.tagTypeList = [
"brand",
"category",
];
this.tags = {};
}
function tagConstructor.prototype.addTag = function(tagType, tag) { // This is line 8 where the error occurs
// Only add tag if tag type exists in tagTypeList
if (this.tagTypeList.indexOf(tagType) > -1) {
this.tags[tagType] = tag;
}
}
function main() {
var test = new tagConstructor();
test.addTag("brand", "Adidas");
test.addTag("gender", "Damen");
}
Upvotes: 2
Views: 57
Reputation: 63524
It's not
function tagConstructor.prototype.addTag = function
It's
tagConstructor.prototype.addTag = function
Upvotes: 2