prop-or

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
If the given, non-null object has an own property with the specified name, returns the value of that property.
1 contributor
Install prop-or as a package?
Copied
npm i @bit/justin-capalbo.ramda.prop-or
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
propOr (
val:*,
p:String,
obj:Object
) : *

If the given, non-null object has an own property with the specified name, returns the value of that property. Otherwise returns the provided default value.

Example
const alice = {
       name: 'ALICE',
       age: 101
     };
     const favorite = R.prop('favoriteLibrary');
     const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');

     favorite(alice);  //=> undefined
     favoriteWithDefault(alice);  //=> 'Ramda'
Arguments
val: *

The default value.

p: String

The name of the property to return.

obj: Object

The object to query.

Returns
*

The value of given property of the supplied object or the default value.

Help and resources