The most accurate way to determine whether an element is a js object
- Use the prototype method
function isObject(val) {
return Object.prototype.toString().call(val).slice(8, -1) == "Object";
}
Because similar typeof or instanceof cannot distinguish between arrays and objects, both of which are objects, only the method of this prototype is possible