Skip to content
Advertisement

Tag: javascript-reflection

Reflect API and Serialization via JSON.stringify

The following JavaScript code does something I didn’t expect. Why is the serialized output from JSON.stringify missing the new bar property? Answer because this property is not enumerable. By default, properties added using Object.defineProperty() are not writable, not enumerable, and not configurable. see documentation : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description so you must do: This is similar for the length property upon arrays:

Advertisement