Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Creating Multiple Instances with Constructors

what the object in constructor function ?

what is object here ?

 function person(name,contact){
  this.name = name;
  this.contact = contact;
}

 var name = new person("john",5445599);

1 Answer

jason chan
jason chan
31,009 Points

An object constructor is a blueprint. Objects are supposed to represent real objects in the world. Think of programming is simulation of the real world, but text based.

 function Person(name,contact){
  this.name = name;
  this.contact = contact;
}

 var name = new Person("john",5445599);

console.log(name.name)
console.log(name.contact)

Be careful to keep constructors as proper casing.

It's basically to create grouping of variables and functions. In object oriented it's called properties and methods. Properties are like variables and methods are functions. I hope that helps.