JSFiddle - React, Tailwind, and code Playground
JavaScript
//'use strict'
// Create a global variable
var john = "Jo";
alert(john); // "Jo"
alert(window.john); // "Jo", works as a property too
// Create a property of the global object
window.jane = "JJ";
alert(jane); // "JJ", works as a variable too
alert(window.jane); // "JJ"
// Delete them
try { alert(delete window.john); } catch (e) { alert(e); }
// false
/* if strict mode were enforced would actually cause
the following fatal error:
TypeError:
property "john" is non-configurable and can't be deleted
*/
try { alert(delete window.jane); } catch (e) { alert(e); }
// true
alert(john); // "Jo"
try { alert(jane); } catch (e) { alert(e); } // undefined in book
/* but actually gives a:
ReferenceError: jane is not defined
which is a fatal error causing the script to exit
if not caught*/
alert(this === window); // true