對象是空的嗎? [重複] - Is object empty? [duplicate]

問題:

This question already has answers here : 這個問題在這裏已經有了答案
Closed 4 years ago . 4年前關閉。

What is the fastest way to check if an object is empty or not?檢查對象是否爲空的最快方法是什麼?

Is there a faster and better way than this:有沒有比這更快更好的方法:

function count_obj(obj){
    var i = 0;
    for(var key in obj){
        ++i;
    }

    return i;
}

解決方案:

參考一: https://stackoom.com/question/KxDd
參考二: Is object empty? [duplicate]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章