JSFiddle - React, Tailwind, and code Playground

JavaScript

console.log('foo: ', typeof foo);
console.log('bar: ', typeof bar);

function a() {
    this.foo = function () {
        this.bar = 123; 
    }; 
}

a()

console.log('foo: ', typeof foo, foo);
console.log('bar: ', typeof bar);

test = {};

foo.call(test);
    
console.log('bar: ', typeof bar);
console.log('test.bar: ', typeof test.bar, test.bar);