JSFiddle - React, Tailwind, and code Playground

by spechackers

JavaScript

function myFunction(){
    this.sayHello = function(){
        console.log(this);
    }
}

myFunction.prototype.newMethod = function(){
    console.log(this);
}

var myInstance = new myFunction();
myInstance.sayHello(); //refers to myFunction constructor
myInstance.newMethod(); //refers to myFunction constructor