怎麼檢查 object 是不是空的?


Posted by Rich on 2021-09-12

有時候會有這種需求,這次解決的幫手是:

let obj = {}
if (Object.keys(obj).length === 0) //true

怕忘記,紀錄一下。










Related Posts

[02] Functional Component

[02] Functional Component

JS 與 Node.js 的執行環境異同

JS 與 Node.js 的執行環境異同

【JS上課筆記】非同步(asynchronous)VS. 同步(synchronous)

【JS上課筆記】非同步(asynchronous)VS. 同步(synchronous)


Comments