Daily-Javascript中判断对象是否存在

Javascript中判断对象是否存在

if(typeof myObj=='undefined'){
    alert('变量不存在');
}

更多写法见阮一峰博客:

http://www.ruanyifeng.com/blog/2011/05/how_to_judge_the_existence_of_a_global_object_in_javascript.html

猜你喜欢

转载自blog.csdn.net/zhaobw831/article/details/79200844