0

I am currently writing an extension for Chrome. When debugging my application, I log a javascript array to the console, as shown below:

function updateGroups() {
  var container = document.getElementById("groups_container");
  var prototype = document.getElementById("group");
  chrome.storage.local.get('groups', function(groups_local) {
    groups = groups_local.groups;
    console.log(groups); //Debug
  });
}

Calling the function twice gives me the following output (the array is at both calls filled with 42 elements):

console output

Why are the two outputs formatted differently, with one just showing the number of elements in the array, and the other actually displaying its elements?

Community
  • 1
  • 1
Robert Hönig
  • 545
  • 1
  • 5
  • 18
  • 1
    Probably because the first ever message in console log is handled differently. Try inspecting the inspector: switch devtools to a [detached window](http://stackoverflow.com/a/10035408/3959875), press Ctrl-Shift-I, then Ctrl-Shift-C and click a message in the first devtools window, then see if there's any difference. Anyway, you can force consistent display via `console.dir` or `console.log.apply(console, groups)` – wOxxOm Jul 23 '16 at 15:42
  • I can follow your instructions until the Ctrl-Shift-C. It does nothing for me. What is it supposed to do? – Robert Hönig Jul 23 '16 at 15:47
  • It's the first button in the devtools toolbar: element picker. – wOxxOm Jul 23 '16 at 15:52

0 Answers0