js判斷陣列、物件為空或者不存在
if(typeof(arr)=='undefined'?false:(arr.length==0?false:true)){
console.log('陣列不為空')
} else {
console.log('陣列不存在或者為空')
}
if(typeof(o)=='undefined'?false:(typeof(o.name)=='undefined'?false:true)){
console.log('物件屬性存在')
} else {
console.log('物件屬性不存在,或者物件不存在')
}