currently I have to support the IE 9
so I cannot use classes and lambda expressions.
I have a function that represents my class and within this function I have another function for creating a new object.
For the scope I have to work with this
but the problem is, there is no
new this.Obj()
this.Obj()
this new Obj()
new (this.Obj())
This is what I tried so far. I created a small example
function Store(originDogs) {
this.Dog = function(name) {
this.name = name;
}
this.originDogs = originDogs;
this.dogs = this.originDogs.map(function(x) {
return new this.Dog(x.name);
});
}
new Store([{
name: "dog1"
}, {
name: "dog2"
}, {
name: "dog3"
}]);
The error I get is
Uncaught TypeError: this.Dog is not a constructor
How do I have to Setup new this.Dog
to make it work?