判断 js 数组是否为 empty
function isEmpty(obj) { for(var key in obj) { if(obj.hasOwnProperty(key)) return false; } return true; }
var mycars = new Array();
mycars[0] = "";
mycars[1] = "";
mycars[2] = "";
console.log(isEmpty(mycars) ? '0' : '1'),
资料来源:
https://coderwall.com/p/_g3x9q/how-to-check-if-javascript-object-is-empty