[object Object]是什么意思? (JavaScript的) [英] What does [object Object] mean? (JavaScript)
本文介绍了[object Object]是什么意思? (JavaScript的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的一个提醒是给出以下结果:
One of my alerts is giving the following result:
[object Object]
这究竟是什么意思? (这是一些jQuery对象的警告。)
What does this mean exactly? (This was an alert of some jQuery object.)
推荐答案
这意味着您正在警告对象的实例。当 alert
对象时,对象上调用 toString()
,默认实现返回 [object Object]
。
It means you are alerting an instance of an object. When alert
ing the object, toString()
is called on the object, and the default implementation returns [object Object]
.
var objA = {};
var objB = new Object;
var objC = {};
objC.toString = function () { return "objC" };
alert(objA); // [object Object]
alert(objB); // [object Object]
alert(objC); // objC
如果要检查对象,则应该 console .log
它, JSON.stringify()
它,或枚举它的属性并使用单独检查它们/ code>。
If you want to inspect the object, you should either console.log
it, JSON.stringify()
it, or enumerate over it's properties and inspect them individually using for in
.
这篇关于[object Object]是什么意思? (JavaScript的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文