JSFiddle - React, Tailwind, and code Playground
by DohanKwon
JavaScript
// variable scope with 'function'
function foo() {
var b = 'access me';
}
console.log('function: ' + (typeof b === 'undefined'));
// variable scope with 'catch'
try {
throw new exception('fake exception!');
}
catch (err) {
var test1 = 'can you see me?';
console.log('catch: ' + (err instanceof ReferenceError === true));
}
console.log('catch: ' + test1);
console.log('catch: ' + (typeof err === 'undefined'));
// variable scope with 'with'
with ({test2: 'you can\'t see me'}) {
var notScope = 'but you can see me';
console.log('with: ' + (test2 === 'you can\'t see me'));
}
console.log('with: ' + (typeof test2 === 'undefined'));
console.log('with: ' + notScope);