In this console:
When B
is set to A
but A
was destroyed afterwards, B.b()
throws an error because A is truly undefined.
How can one avoid this?
PS: I am aware that I can simply return this
(or change the function in some way) but that doesn't fulfill my purposes.
EDIT: How do I 'localise' and somehow tell javascript that by A
, I mean B
even if A is undefined, WITHOUT ALTERING THE FUNCTION ITSELF?