127

JS如何判断一个对象为空 - CSDN博客

 6 years ago
source link: http://blog.csdn.net/wky_csdn/article/details/77945313
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
昨天面试的时候被问到的问题。只怪自己根基不牢,没有回答好。然后面试官提示用for in,突然恍然大悟,然后又查询了网上的一些方法,对这个问题做一下整理。1、最常见的思路,for…in…遍历属性,为真则为“非空数组”;否则为“空数组”var judgeObj = function(obj){ for(var item in obj){ return true; }

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK