当前位置:编程学习 > JS >>

js,代码中"object"和"Object"区别?

var testname = new Object(); document.write(getType(testname)); function getType(x) { if(x == null) { return "null"; } var t = typeof x; if(t != "object") { return t; } var c = Object.prototype.toString.apply(x); c = c.substring(8, c.length-1); if(c != "Object") { return c; } if(x.constructor == Object) { return c; } if("classname" in x.constructor.prototype && typeof x.constructor.prototype.classname == "string") { return x.constructor.prototype.classname; } return "<unknow type>"; } 上面的代码中:各个判断的"object"、"Object"、"x.constructor == Object"有什么区别?,还有最后的"classsname"这个什么意思?
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,