I want to be able to assign function from another class name in javascript. Here is what i mean in script:
classA = function() {
this.direction = 1;
this.someFunction = function() {
this.direction = 0;
}
}
classB = function() {
this.direction = 2;
this.anotherFunction = classA.function
}
objA = new classA;
objB = new classB;
objB.anotherFunction();
console.log(objB.direction); // 0
console.log(objA.direction); // 1
How can I achieve that? I can't find much information about the prototype variable of javascript but i feel like this is possible with that.
EDIT: Fixed a typo
objB = new objB;?objB.anotherFunction = objA.someFunction