好好爱自己!

js判断object的具体类型(或者说判断object的类class)

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 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?

 

posted @ 2017-08-29 20:14  立志做一个好的程序员  阅读(2433)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处