What's the JS equivalent of this rgss3 code?
Object.method:)method_name).call(params)
Thanks.
JS equivalent of .method().call()?
● ARCHIVED · READ-ONLY
-
-
<method>.call(<thisarg>, [<param1>, <param2>, ...]);
See here: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Function/call
The first parameter decides what "this" inside the method should point to. If you are running in strict mode, undefined or null will be left as-is, while in non-strict mode they will be replaced with the global window object.
Alternatively, you can use apply instead of call, which takes an array-like object for the parameters. -
OBJECT.prototype.METHOD.call(this, PARAMS)
OBJECT.METHOD.call(this, PARAMS)
I think it would be like this, depending on how your methods are defined.
Methods are just properties of objects, and prototype isn't that special either. As long as you specify the scope, -
If you mean a dynamic name:
Code:object[method]() object[method].call() object[method].apply() -
Yeah I mean calling a dynamic method name since I mostly use them back in Ace instead of eval.