Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is not a surprise that overriding the implementation of an operator’s type coercion works and overrides the behavior of the operator’s type coercion.


Do you really think that most JavaScript users are aware that “overriding the implementation of an operator’s type coercion” is a language feature?

Sure, you can claim that everyone should know this obscure feature when they don’t. But that’s how this language enters C++ territory.


I actually don't think you are wrong, but I'm not backing that up with any actual data.

I happened to know it because of how the hyperHTML micro-library works; the author went into great detail about it and a ton of other topics. But my gut would say that the average js dev doesn't know about it.

But then... it's useful for creating component frameworks which... most js devs use. Which doesn't mean they know how they work under the hood. But... a lot of devs I've met specifically choose a framework because of how it works under the hood.

... so... I really have no idea how many people know this. I'm still betting it's less than average.


Well, Proxy objects do allow you to override the behavior of any property, including Symbol properties. Symbol.iterator is pretty widely used to create custom iterable objects, so I would expect curious devs to have taken a look at what else can be done through the use of Symbol properties.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: