JSFiddle - React, Tailwind, and code Playground

JavaScript

var helloClass = function () {
     // this is an instance of hello class
     this.hey = function () {
         console.log("calling as class - hey");
     }

     var _this = this; // creating this context of hello
     function init() {
         // this is a context of window here
         //this.hey(); // throws an error
         _this.hey(); // will execute
     }
     init();
 }
 var h = new helloClass(); // create a new instance/object of hello

/*************************************/
var helloFunction = function () {
     // this is a context of window here
     this.hey = function () {
         console.log("calling as function - hey");
     }

     function init() {
         // this is a context of window here
         this.hey(); // will execute
     }
     init();
 }
 var h = helloFunction(); // calling a hello function