Message from JavaScript discussions

December 2017

— Https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70?source=linkShare-ddf3465630b5-1513273246

Message permanent page

— 

I want the this var for Kernel.prototype.sysCallProcedures.ANYTHING to be set to the instance of Kernel

— But because they're in the sysCallProcedures object, this is undefined unless I use apply or call

— 

var test = function () {
this.thing = "Hello world";
};
test.prototype.stuff = {
testFunc: function () {
console.log(this.thing);
}
};
var testInstance = new test();
testInstance.stuff.testFunc();
VM505:6 undefined

Message permanent page

— Example code

— 

testInstance.stuff.testFunc.call(testInstance);
VM505:6 Hello world

— This is what I am doing in prod code right now, that I dislike a lot ^

— Https://stackoverflow.com/questions/28801859/using-this-within-nested-prototype-sub-objects
this says bind, ugh

Message permanent page

— Meh, maybe I can make a new sysCallProcedures class that accepts a thisArg as an argument to the constructor

Message permanent page

— Then at least I don't have to create a ton of new functions, and also I don't have to use apply or call in my logic (just inside the class)

Message permanent page

— Correct

— 

Kernel.prototype.sysCallInterface.someCall

gets routed to
Kernel.prototype.sysCall(call)

which calls
Kernel.prototype.sysCallProcedures.someCall

Message permanent page