Difference Between in and hasOwnProperty in javascript

Let me explain you briefly

⊕ in:

basically its a keywork in javascript, it checks whether the  propreties there are not in the object as well as its prototype chain.

  1. If properties are there it returns true
  2. otherwise false.

but

⊕ hasOwnProperty: 

it is also a keyword in javascript, it checks for the prorperties only in the object itself but not its prototype chain.

  1. If properties are there it returns true
  2. otherwise false.

Note:  every object has prototype in javascript.

please refer the link below for more information

Difference Between in and hasOwnProperty in javascript

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s