runners3431
runners3431

Reputation: 1455

How do I see what [object Object] refers to in Chrome Tools?

In chrome tools, how can i view what [OBJECT object] represents? Testing out function context of keyword 'this'

 var Calculator = function (eq) {

            // private members...
            var eqCtl = document.getElementById(eq),
                foo = function () { };

            return {
                add: function (x, y) {
                    var val = x + y;
                    eqCtl.innerHTML = val;

                },

                print: function () {
                    console.log("print:  this" + this);
                    this.test(this);
                },

                test: function (obj) {
                    console.log("test: this " + this);
                    console.log("this: obj" + obj);
                }


            }

        };

Upvotes: 0

Views: 45

Answers (3)

MxLDevs
MxLDevs

Reputation: 19506

Try console.dir instead. It should be more informative than console.log under certain situations.

Upvotes: 0

Satpal
Satpal

Reputation: 133403

Pass multiple parameters to console.log method

console.log("this: obj", obj);

Upvotes: 0

Matt Ball
Matt Ball

Reputation: 359786

Don't convert it to a string. console.log() it separately:

console.log("test: this ", this);
console.log("test: obj ", obj);

Upvotes: 1

Related Questions