On Fri, Nov 24, 2017 at 11:38 AM, Renan Bastos <[email protected]>
wrote:
>
> Hey guys,
>
> I communicate that when we go use the escape to object JSON it
> don't escape correctly.
> So I think we should add this suggestion.
>
> const obj2 = {"name": "NodeJS", "version": "all"};
> console.log(escape(obj)); //%5Bobject%20Object%5D

I don't see any need to do that. `escape(JSON.stringify(obj))` is not
over-long. Small, composable functions are a good thing. And if you want to
define a `escapeAsJSON` function, it's easy to do that in your code.

I do see reasons *not* to do it: We'd have to handle the situation where an
object overrides `toString` and is expecting the string from that, not
JSON, to be used by `escape(obj)`. Handling that would be ugly, it would be
along the lines of "Get `toString` from the object. If `toString` is not
`%ObjProto_toString%`, then..."

-- T.J. Crowder
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to