I'm using typescript to design classes using the concept of Dependencies injection design pattern. Inside the code of Injector class there is line of code: car.apply(car, [new doors]); We suppose to execute the main class then we can use the (dependencies, methods) as we inject them as argument BUT the truth that the .apply does not execute the function!! So what is happening exactly ??
var car = function (){
function car(doorsClass){
this.doorsClass = doorsClass;
this.color('red');
this.doorsNum(4);
}
car.prototype.color = function(color){
console.log('Car color is '+color);
}
car.prototype.doorsNum = function(doorsNum){
console.log('Car has '+this.doorsClass.doors(doorsNum)+' doors');
}
return car;
}
var doors = function (){
function doors(){ }
doors.prototype.doors = function(num){
return num;
}
return doors;
}
car.apply(car, [new doors]);