Home > Web Front-end > JS Tutorial > Javascript method to determine whether a function exists_javascript skills

Javascript method to determine whether a function exists_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:44:47
Original
982 people have browsed it
Copy code The code is as follows:

window.onload=function(){
try{

if(test&&typeof(test)=="function"){
test();
}else{
alert("Function that does not exist");
}
}catch(e){
}
}
function test(){
alert("Function execution...");
}

If not If it exists, an exception will be thrown, so try...catch must be added.
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template