Check if Javascript function exists or is defined
- Article
- Comment
Check if Javascript function exists or is defined . On certain situations, we have to check the function whether it has definition or exist to call. Else we have to bear some errors and it will affect next programs, than, total Javascript results failed to run. Its quite good idea to check whether a function exist or not, which will prevent problems of js errors on function call. Let me give you the simple code to check it .
if (typeof my_custom_function_kvcodes == 'function') { my_custom_function_kvcodes(); }
here, the custom function may be defined on a separate or another file.
function my_custom_function_kvcodes() { // Here your custom codes ... }
thats’ it.