You can assign something “unique” to the [varName] window, and then check if the actual value matches:
varName = "myvar" isGlobal = false test = "some unique string" savedValue = window[varName] window[varName] = test try { isGlobal = eval(varName + "==='" + test + "'") } catch(e) {} window[varName] = savedValue
isGlobal will be true if myvar is global and not obscured in the current area.
georg source share