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

typeof

  • typeof “text”  —->   string
  • typeof 123   ——      number
  • typeof Nan  ——>  number
  • typeof “123”——>  string
  • typeof []——>  object
  • typeof {}——>  object
  • typeof null——>  object
  • typeof false——>  boolean
  • typeof true——>  boolean