Check if a value is an object in JavaScript

后端 未结 30 3375
臣服心动
臣服心动 2020-11-22 05:06

How do you check if a value is an object in JavaScript?

30条回答
  •  别跟我提以往
    2020-11-22 05:57

    If typeof yourVariable === 'object', it's an object or null. If you want to exclude null, just make it typeof yourVariable === 'object' && yourVariable !== null.

提交回复
热议问题