JSFiddle - React, Tailwind, and code Playground

by spechackers

JavaScript

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

myFunction() //this here refers to global scope, coz your myFunction is being called from the global context. 

var obj = {};

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

obj.sayHello(); // this here refers to the object, as object is invoking and not the global scope.