How to know a javascript function exist or not
By doing below we can know --
1. function abc() {
}
if (typeof abc != 'undefined' && $.isFunction(abc)) {
alert('abc exists');
} else {
alert('abc does not exist');
}
if (typeof def != 'undefined' && $.isFunction(def)) {
alert('def exists');
} else {
alert('def does not exist');
}
2. try {
abc()
}
catch(e){alert("abc doesn't exist")}
Post a Comment