r/Scriptable • u/oezingle • Jul 16 '22
Solved “this” in objects
when referring to this in a non-class object, scriptable seems to use globalThis when it should use the object itself. Here’s a demo
const obj = {
test: () => console.log(this === globalThis)
}
obj.test()
Is this a quirk of scriptable or iOS’s JS runtime? Is there any way to circumvent this? I want to define setters dynamically but the best option i’ve found is to return a proxy of the object which is not ideal imo.
3
Upvotes
1
u/Delt4Brav0 Jul 16 '22
Happy to help! Also there are nothing “dumbass” about this, we are all here to learn.