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.

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct