Why does JSON.stringify not serialize non-enumerable properties?

It’s specified in the ES5 spec.

  1. If Type(value) is Object, and IsCallable(value) is false

    • a. If the [[Class]] internal property of value is "Array" then

      • i. Return the result of calling the abstract operation JA with argument value.
    • b. Else, return the result of calling the abstract operation JO with argument value.

So, let’s look at JO. Here’s the relevant section:

Let K be an internal List of Strings consisting of the names of all the own properties of value whose [[Enumerable]] attribute is true. The ordering of the Strings should be the same as that used by the Object.keys standard built-in function.

Leave a Comment