Given a function,
function main() {
// some logic
}
Lets assume the function main
is bind with const obj = { name: "John Doe" }
like const fn = main.bind(obj);
Now the question is, Is there a way to get the fn
function binding?
Note: i know binding can be accessed using the this
keyword inside the main
function but is there any way to access this
value outside the context. is there any magic (hypothetical) method like fn.getContext()
.
Thank you for your time.
No there is not. While the new function object has an internal [[BoundThis]]
slot, that slot is not accessible via a user-facing API.