Function

getWithDefault (obj, keyName, defaultValue) Object public deprecated

Module: @ember/object
import { getWithDefault } from '@ember/object';
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.

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

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/3.25/functions/@ember%2Fobject/getWithDefault