Suppose I have a JavaScript function like this:
function f(DOM_Path) {
if (typeof DOM_Path !== 'undefined') {
// Do something
}
}
Now suppose I were to pass this a variable identified by its DOM path like so:
f(document.html);
This would throw an error if document.html were undefined even before f() checked for this. To get around this, I'd need some way to pass the path to the variable as a string, like so:
f('document.html');
But if I do this, how can I edit f() to check whether the variable at this path is undefined, and otherwise use the path as the path to a variable rather than a string?