Serialization of RegExp
So, I was interested to find that JSON.stringify reduces a RegExp to an empty object-literal ( fiddle ): JSON.stringify(/^[0-9]+$/) // "{}" Is this behavior expected? I realize that a RegExp is an object with no properties to serialize. That said, dates are objects too; yet JSON.stringify() manages to produce a meaningful string: JSON.stringify(new Date) // "2014-07-03T13:42:47.905Z" I would have hoped that JSON would give RegExp the same consideration by using RegExp.prototype. toString() . Yes, because there's no canonical representation for a RegExp object in JSON. Thus, it's just an empty