The JavaScript specification gives exactly one proper way to determine the class of an object:
Object.prototype.toString.call(t);
http://bonsaiden.github.com/JavaScript-Garden/#types
https://stackoverflow.com/questions/7893776/the-most-accurate-way-to-check-js-objects-type
The most accurate way to check JS object‘s type?
Ask Question
The typeof
operator doesn‘t really help us to find the real type of an object.
I‘ve already seen the following code :
Object.prototype.toString.apply(t)
Question:
Is it the most accurate way of checking the object‘s type?
js判断object的具体类型(或者说判断object的类class)
原文地址:http://www.cnblogs.com/oxspirt/p/7450083.html