enumerable
enumerable Defines whether the property is enumerable and is serialized by .serialize().
Boolean
Specifies if the property should be enumerable. By default, all properties except for ones with defined getters, async, and value are serialized.
You can prevent a property from being serialized like:
import { ObservableObject } from "can/everything";
class MyMap extends ObservableObject {
static props = {
propertyName: {
enumerable: false
},
secondPropertyName: String
};
}
const map = new MyMap({ propertyName: "foobar", secondPropertyName: "bar" });
console.log( map.serialize() ); //-> {secondPropertyName: "bar"}
Make a getter property part of the serialized result like:
import { ObservableObject } from "can/everything";
class MyMap extends ObservableObject {
static props = {
propertyName: {
get() {
return "test";
},
enumerable: true
}
};
}
const map = new MyMap();
console.log( map.serialize() ); //-> { propertyName: "test" }
enumerable also controls for/in
loops, Object.assign, and Object.keys, among others. See enumerability for more information.