3 ms·
But even if you use an arbitrary object....if it comes from a user supplied value you are going to have to validate it somehow. It would be great if the post i
by grannyg00se 15y ago
But even if you use an arbitrary object....if it comes from a user supplied value you are going to have to validate it somehow.
It would be great if the post included good examples of how these things are going to produce better code. Maybe my imagination or experience is just insufficient to see the great win here.
- tolmasky 15y agoValidated or not there are still many cases where this is a valid key and thus completely breaks the object. For example, this might be a login name, most people would consider it unreasonable to not allow js keywords as logins. For a simpler example, imagine a dictionary of syntax highlighted words for js ;) There are workarounds of course, but the ironic result is that when you want to use a js object as an actual hash/dictionary (something we are repeatedly told js is great at), your code devolves into a defensive programming mess, requiring constructions like Object.prototype.hasOwnProperty.apply, etc.