Default values for specified properties

# T.J. Crowder (7 years ago)

Fairly basic specification comprehension question: Is it correct that the message property of Error.prototype is specified as non-enumerable, because its definition doesn't explicitly say otherwise and so the default properties listed in Table 4 of Property Attributes apply?

-- T.J. Crowder

# Allen Wirfs-Brock (7 years ago)

tc39.github.io/ecma262/#sec-ecmascript-standard-built-in-objects

"Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified."

# T.J. Crowder (7 years ago)

Brilliant, thanks Allen!

-- T.J. Crowder

# Michael J. Ryan (7 years ago)

I've always felt that made cloning and serializing Error based instances particularly fun.

# T.J. Crowder (7 years ago)

On Fri, Apr 21, 2017 at 12:11 PM, Michael J. Ryan <tracker1 at gmail.com>

wrote:

I've always felt that made cloning and serializing Error based instances particularly fun.

Well, the one on Error.prototype is just the "" default anyway. But yes, the fact that Error makes the message "own" property it creates non-enumerable is slightly surprising. I'm guessing there's history there. :-)

-- T.J. Crowder

# Michael J. Ryan (7 years ago)

I always assumed it was an implementation detail historically... stack is also not enumerated, though message is more surprising... I tend to remember for logging/server purposes in particular, and call it out in my clone library, as I've been hit by it many times.

# Allen Wirfs-Brock (7 years ago)

On Apr 21, 2017, at 4:42 AM, Michael J. Ryan <tracker1 at gmail.com <mailto:tracker1 at gmail.com>> wrote:

I always assumed it was an implementation detail historically... stack is also not enumerated, though message is more surprising... I tend to remember for logging/server purposes in particular, and call it out in my clone library, as I've been hit by it many times.

ES1 (1997) Clause 15:

"Every other property described in this section has the attribute { DontEnum } (and no others) unless otherwise specified."

Error.prototype and its properties were added to clause 15 in ES3.