Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

has-own-property

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
5,240
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 years ago
SIZE
478 B
Determines whether the object has the specified property.
2 contributors
Use has-own-property in your project ?
Copied
npm i @bit/bit.utils.object.has-own-property
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
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';
revert changes
reload
toggle layout
maximize
hasOwnProperty(
  {
    foo: "bar"
  },
  "foo"
hasOwnProperty(
  {
    foo: "bar"
  },
  "bar"
modifieddraft
chevron_left
chevron_right
hasOwnProperty (
obj:object,
prop:(string | number)
) : boolean

Determines whether the object has the specified property.

Example
hasOwnProperty({foo: 'bar'}, 'foo') // => true
 hasOwnProperty({foo: 'bar'}, 'bar') // => false
Arguments
obj: object
prop: (string | number)

property to test

Returns
boolean

Test Summary

#hasOwnProperty() should return false as given object do not contain key bar

Pass

#hasOwnProperty() should return true as given object contains key foo

Pass

#hasOwnProperty() should return false if key is null

Pass