JSFiddle - React, Tailwind, and code Playground

JavaScript

function usesThis(name) {
    this.myName = name;

    function returnMe() {
        return this;		//scope is lost because of the inner function
    }
    
    return {
        returnMe : returnMe
    }
}

function usesThat(name) {
    var that = this;
    this.myName = name;

    function returnMe() {
        return that;			//scope is baked in with 'that' to the "class"
    }
    
    return {
        returnMe : returnMe
    }
}

var usesthat = new usesThat('Dave');
var usesthis = new usesThis('John');
alert("UsesThat thinks it's called " + usesthat.returnMe().myName + '\r\n' +
      "UsesThis thinks it's called " + usesthis.returnMe().myName);