Let’s have some fun with JavaScript! First, we’ll define a Person:

var Person = function () { };
Person.prototype = {
  isPerson: function () {
    return true;

Then we’ll create a NotPerson, who is definitely not a person, but is a special function:

var NotPerson = function () {
  return new Person();

NotPerson.prototype = {
  isPerson: function () {
    return false;

And now:

new Person().isPerson(); // true
new NotPerson().isPerson(); // also true


new NotPerson() instanceof Person; // true
new NotPerson() instanceof NotPerson; // false

Fun stuff! When you create a new object in JavaScript with new, an Object is created to act as this. Normally, the this instance is returned to the caller (with a prototype attached), but you can return something else and the called will receive it instead.

You can use this to pass back cached instances of an object, or proxy other objects.