mardi 13 décembre 2022

Reflect API and Serialization via JSON.stringify

The following JavaScript code does something I didn't expect.

let foo = {};
Reflect.defineProperty(foo,'bar',{value:1});
console.log(foo); // { bar: 1 }
console.log(JSON.stringify(foo)); // { }

Why is the serialized output from JSON.stringify missing the new bar property?





Aucun commentaire:

Enregistrer un commentaire