Create an object with the Person() constructor and then call the full_name() method.

function Person(first_name, last_name) {
  this.first_name = first_name;
  this.last_name = last_name;
  this.full_name = function () {
    return this.first_name + " " + this.last_name


var crazy_pants = new Person("crazy", "pants");

The arguments that are passed to the Person() constructor function are used to create properties of the object.

Notice that the "this" keyword refers to the object that is being created in constructor functions. In the full_name() method of the constructor function, this.first_name and this.last_name refer to properties of the person object that is being created by the constructor function.


© 2017