I want to check if a function is defined (I don't care how, I mean it is callable)
sample code:
var functions = {
'alert':'alert',
'undefinedFunction':'undefinedFunction',
'ff.showAlert':'ff.showAlert'
};
var ff = {
showAlert: function() {
alert('the function works');
}
};
for (i in functions) {
console.log(i+' : '+typeof window[functions [i]]);
}
this returns:
alert : function
undefinedFunction : undefined
ff.showAlert : undefined
console.log(typeof window.ff.showAlert); return function
Live demo
Is there a way to programmatically check if a function exists?