You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure about this, it common pattern, and most time, it mean to used as method call, the problem is not how the object defined, but how it's used.
I don’t think it’s any less safe than using it in classes. A class method obj.foo is indistinguishable from an object property obj.foo, so in both cases one has to be aware of this.
There’s some merit to avoiding this in objects, I think, but then there’s also situations where people might want to use this and explicitly bind the function, like obj.getName.call(user)
I can’t say I used any of these patterns in a very long time though.
Description
It is unsafe to use this in an object's properties
It may contain potential bugs
Fail
Pass
Proposed rule name
no-this-in-object-expression
Additional Info
No response
The text was updated successfully, but these errors were encountered: