Message from JavaScript discussions
December 2017
— I get I can use rest operator again instead of apply
too, but apply
actually is needed here
Example real code:
FORK_CHILD: function (bg = false, ...args) {
const pid = this.sysCallProcedures.FORK.call(this, bg, ...args);
this.curProc.childPids.add(pid);
return pid;
},
— That was one of my first thoughts but they're part of the prototype
— Kernel.prototype.sysCallProcedures
— This is a great post for new people in js
— Https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70?source=linkShare-ddf3465630b5-1513273246
— 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
— 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 ^