Sign in
Log inSign up

Function Constructor in Javascript

Default profile photo
Anonymous
·Mar 29, 2018
function Person(firstname, lastname) {
    this.kk="hgvv";          
    this.firstname = firstname;
    this.lastname = lastname;

    return true;
}

var john = new Person('John', 'Doe');
console.log(john);

Here I am returning true ,But I am getting object with properties kk,firstName,lastName.

I am unable to understand what is going under the hood.