Function
get (obj, keyName) Object public
Defined in packages/@ember/-internals/metal/lib/property_get.ts:41
import { get } from '@ember/object'; |
- obj
- Object
- The object to retrieve from.
- keyName
- String
- The property key to retrieve
- returns
- Object
- the property value or `null`.
Gets the value of a property on an object. If the property is computed,
the function will be invoked. If the property is not defined but the
object implements the unknownProperty
method then that will be invoked.
1 2 |
import { get } from '@ember/object'; get(obj, "name"); |
If you plan to run on IE8 and older browsers then you should use this method anytime you want to retrieve a property on an object that you don't know for sure is private. (Properties beginning with an underscore '_' are considered private.)
On all newer browsers, you only need to use this method to retrieve
properties if the property might not be defined on the object and you want
to respect the unknownProperty
handler. Otherwise you can ignore this
method.
Note that if the object itself is undefined
, this method will throw
an error.