Call of object.method from event gets empty object #1585
Replies: 4 comments
-
Posted at 2021-12-03 by myownself Yes, this is normal. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-03 by @gfwilliams yes, it's because
You can always just do:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-03 by Mark_M Thank you myownself and Gordon! Will know. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-12-04 by @allObjects Mark_M this is an alternative of 'wrapping' - .bind() :
For Btw, in JS same upper/lower/camel-casing as Java is useful. Constructor functions - like Classes in Java (and other 'like-minded' languages) - have an uppercase initial. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-12-03 by Mark_M
I do not have much experience with JavaScript (have quite a bit with Java).
It is weird issue from my perspective. If I assign an object's method call to event, it runs in empty object instance. All fields are empty. But if I wrap object's method into a function, and put into event, it runs ok. Is it normal?
Example:
Output of direct method assignment
Output of wrapped method assignment
Beta Was this translation helpful? Give feedback.
All reactions