javascript - Console.log a multi-dimensional array -


so have created multi-dimensional array: (i.e. 1 2 sets of 'coordinates')

var items = [[1,2],[3,4],[5,6]]; 

my site in development , array, when loaded, , contains changing, need able to, whilst running script, dynamically view contents of array.

so, use this:

console.log(items); 

to output console. gives me following output:

alt: unreadable output of array

so, there other way in can equivalent of console.logging array, more readable output?

you can use javascript's console.table

this display array in table form, making more readable , easy analyse
quite little known feature, useful when have multi-dimentional array.

so, change code console.table(items);
should give this:

  ----------------------- |(index)|   0   |   1   | |   0   |   1   |   2   | |   1   |   3   |   4   | |   2   |   5   |   6   |  ----------------------- 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -