Object.addPropertiesWithDefaults

Allows to specify what properties need to be added if not there yet. When added, the property is initialized with either value from optional source or default value. If default value is observable then added property will be the very same observable with either source or default value.

Syntax

Object.addPropertiesWithDefaults( destination, { propertyToAdd: <defaultValue> }, optionalSource )

Examples

Simple example

Result will be equal to

Example with observables

Result will be equal to

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.