Function

obj
Object
The object to retrieve from.
keyName
String
The name of the property to retrieve
defaultValue
Object
The value to return if the property value is undefined
returns
Object
The property value or the defaultValue.

Retrieves the value of a property from an Object, or a default value in the case that the property returns undefined.

1
2
import { getWithDefault } from '@ember/object';
getWithDefault(person, 'lastName', 'Doe');