What does [object Object] mean?

后端 未结 10 2160
醉酒成梦
醉酒成梦 2020-11-22 03:22

I am trying to alert a returned value from a function and I get this in the alert:

[object Object]  

Here is the JavaScript code:



        
10条回答
  •  滥情空心
    2020-11-22 04:13

    It's the value returned by that object's toString() function.


    I understand what you're trying to do, because I answered your question yesterday about determining which div is visible. :)
    The whichIsVisible() function returns an actual jQuery object, because I thought that would be more programmatically useful. If you want to use this function for debugging purposes, you can just do something like this:

    function whichIsVisible_v2()
    {
        if (!$1.is(':hidden')) return '#1';
        if (!$2.is(':hidden')) return '#2';
    }
    

    That said, you really should be using a proper debugger rather than alert() if you're trying to debug a problem. If you're using Firefox, Firebug is excellent. If you're using IE8, Safari, or Chrome, they have built-in debuggers.

提交回复
热议问题