UX Design and Development course

Working with custom functions and object properties

Use a constructor function (or blueprint) for the objects we want to create

var person = function (name, age) {
  this.name = name;
  this.age = age;

Creating an instance of an object the keyword new tells JS that we are creating the new instance of a variable.

var father = new person("Dale Sande", 40);
var daughter = new person("Zoe Sande", 7);

Now that we have created new objects using the constructor function, we can read those values.


Play with code

JS Bin