Check if a value is an object in JavaScript

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

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

30条回答
  •  醉话见心
    2020-11-22 05:52

    When everything else fails, I use this:

    var isObject = function(item) {
       return item.constructor.name === "Object";
    }; 
    

提交回复
热议问题