JSFiddle - React, Tailwind, and code Playground
JavaScript
//console.log(variable); //This line gives you an error. Since variable is not declared
//So, question is about checking the variable declaration, either is defined or not
//var variable = 'Yo';
//Below lines returns string empty when variable is not defined.
//If variable is defined, this gives you the variable value. Since its exists
//var values = typeof variable !== 'undefined' ? variable : '';
var values = typeof variable !== 'undefined' ? 'Declared' : 'Not Declared';
console.log(values);
console.log('So, its working, You are wrong Bro!!!');