JavaScript Objects Deep-Dive

Types of Object properties

Constructor Function:

  •  

  • "Constructor function" and "function constructor" are completely,

function Person (person_name, person_age, person_gender) {

    this.name = person_name,
    this.age = person_age,
    this.gender = person_gender,

    this.greet = function () {
        return ('Hi' + ' ' + this.name);
    }
}

Person.prototype = {
  getUserName(){
    return this.name
  }
}

const person1 = new Person('yash', 30, "Male")
person1