JSFiddle - React, Tailwind, and code Playground

by Christophe

JavaScript

var x = 42;

function alertXs() {
    this.x = 'not 42'; // this = window
    var x = '42 not'; // local x
    
    alert('window.x = ' + window.x); // 'not 42'
    alert('this.x = ' + this.x);     // 'not 42'
    alert('x = ' + x);               // '42 not'

}

alertXs();