Reputation: 1455
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
Reputation: 19506
Try console.dir
instead. It should be more informative than console.log
under certain situations.
Upvotes: 0
Reputation: 133403
Pass multiple parameters to console.log
method
console.log("this: obj", obj);
Upvotes: 0
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