码迷,mamicode.com
首页 > Web开发 > 详细

js 判断js函数、变量是否存在

时间:2014-10-24 23:29:56      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:io   ar   on   cti   ef   type   js   return   函数   

//是否存在指定函数 
function isExitsFunction(funcName) {
    try {
        if (typeof(eval(funcName)) == "function") {
            return true;
        }
    } catch(e) {}
    return false;
}
//是否存在指定变量 
function isExitsVariable(variableName) {
    try {
        if (typeof(variableName) == "undefined") {
            //alert("value is undefined"); 
            return false;
        } else {
            //alert("value is true"); 
            return true;
        }
    } catch(e) {}
    return false;

js 判断js函数、变量是否存在

标签:io   ar   on   cti   ef   type   js   return   函数   

原文地址:http://www.cnblogs.com/wangluochong/p/4049482.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!