How can I check if a dynamically named object or function exists?
In example:
var str = \'test\';
var obj_str = \'Page_\'+str;
function Pag
Your example is right, except drop the parenthesis after obj_str():
if(typeof obj_str != 'undefined') alert('ok');
else alert('error');
This is a bit more correct than window[obj_str] because obj_str may be defined in a local closure, or if you have nested closures, in a containing closure but not in window itself.