版权声明:转载请注明出处链接! https://blog.csdn.net/qq_40259641/article/details/84984913
函数是否定义:
<script type="text/javascript">
try {
if(typeof FunName === "function") { //FunName为函数名称
alert("is function");
} else {
alert("not a function");
}
} catch(e) {}
</script>
变量是否定义:
<script type="text/javascript">
try {
if(typeof myvalue==="undefined") { //myvalue为变量名称
alert("is value");
} else {
alert("not a value");
}
} catch(e) {}
</script>