I have some code where I need to call a function when I have it's name in a string. For example:
var util = {
exByName: function(name) {
window[name](arguments);
}
};
util.exByName("console.log", "blah");
When I run this, the error 'Uncaught TypeError: window[name] is not a function' however, when I ran this in the browser (Opera):
window["console.log"]("blah");
It works fine. Can someone help me with this?
window.onloador a$(function(){...})then it's not in the window scope.window["console.log"]("blah");does not work in chrome... unless someone didwindow["console.log"] = console.log.bind(console);