JSFiddle - React, Tailwind, and code Playground
JavaScript
'use strict';
var a = 'John';
window.b = 'Jane';
try { c = 'Jack'; } catch (e) { alert(e); } // throws ReferenceError: assignment to undeclared variable c
alert(a); // John
alert(b); // Jane
try { alert(c); } catch (e) { alert(e); } // throws ReferenceError: c is not defined
alert(window.a); // John
alert(window.b); // Jane
alert(window.c); // undefined
try {
// Uncommenting any of these three following statements will cause the script to be exited
// during the parsing time; no statement from this script will be executed.
//alert(delete a); // false
//alert(delete b); // true
//alert(delete c); // true
} catch (e) { alert(e); }
alert(a); // John
try { alert(b); } catch (e) { alert(e); } // Jane
try { alert(c); } catch (e) { alert(e); } // throws ReferenceError: c is not defined
window.b = 'Jane';
c = 'Jack';
try {
//alert(delete window.a); // causes script to end during runtime even though try catch block present
//alert(delete window.b); // causes script to end during runtime even though try catch block present
//alert(delete window.c); // causes script to end during runtime even though try catch block present
} catch (e) { alert(e); }
/* Script stops execution at this point. Why?????
alert(window.a); //
alert(window.b); //
alert(window.c); //
alert(a); //
try { alert(b); } catch (e) { alert(e); } //
try { alert(c); } catch (e) { alert(e); } //