Re:Understanding JavaScript Objects
by crooked-v on Friday July 27, 2018 @01:48PM
(#17627725)
In JS, everything that's not a primitive is an object, and primitives can themselves be implicitly coerced to objects. That is to say, these are equivalent:
Functions are really just objects that can be invoked as a function, and they can have properties and even prototypes set the same as any other object. This used heavily in React:
[ Parent
| on HN ]
Re:Understanding JavaScript Objects
by kevin_thibedeau on Friday July 27, 2018 @04:24PM
(#17629036)
The problem is that in the latter case the function object doesn't know what it's name is. This pattern gets unnecessarily abused just to be cool or follow the cargo cult.