isVarDefined method
Returns true if the name is defined in JavaScript runtime.
Implementation
bool isVarDefined(String name) {
String used = runtime.evaluate("""
try {
(typeof $name === 'undefined') ? 0 : 1;
} catch(e) {
0;
}
""").stringResult;
return used == '0' ? false : true;
}