danial
danial

Reputation: 4098

Javascript customize console.log

On google chrome debugger console:

var array = ['item1'];
array //will print ["item1"]

Object.defineProperty(array, '1', {get: function(){return 'item2';}, set: function(v){}});
array //will print nothing

Is there a way to make the last line print some info? console.log(array) also just prints ['item1']. I just need it for debugging purposes.

This actually works fine in firefox. In Safari I get ["item1", undefined × 1].

Upvotes: 0

Views: 134

Answers (1)

pax162
pax162

Reputation: 4735

If you are using chrome, try console.dir(array).

Upvotes: 2

Related Questions