We are going to explore JavaScript’s hasOwnProperty() method in this article. hasOwnProperty() method checks whether the property on an object belongs to the mentioned object or not. If the property belongs to the mentioned object then it will return true else it will return false.

Object’s member inherit the hasOwnProperty() method. This function is used to find out whether the object has the mentioned property directly related to the object.

JavaScript hasOwnProperty() Syntax


property: Pass the string name or symbol to check whether it belongs to the object.


let user = {
name: 'Sathish Kumar',
email: 'ramsatt@gmail.com',
city: 'Chennai',
Country: 'India'

//It returns true

//It returns false
//Because the user object does not have the property mobile