Question: Why does the Chrome console show the array in different ways?

Question

Why does the Chrome console show the array in different ways?

Answers 1
Added at 2016-12-28 14:12
Tags
Question

I wrote a piece of code like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var arr = [1, 45, 37, 5, 48, 15, 37, 26, 29, 2, 46, 4, 17, 50, 52];
        console.log(arr);
    </script>
</head>
<body>

</body>
</html>

Then I found a weird thing, if I open this file in the browser then F12 to call the console, the array is simplified. And if you refresh this page, the console shows the detail of this array.

enter image description here

And if I input the url with the devtool on, it also shows the detail.

Why is that?

Answers to

Why does the Chrome console show the array in different ways?

nr: #1 dodano: 2016-12-28 14:12

It's simply done for performance reasons. If the console is closed, there is no sense displaying the entire array out (Which would require chrome to read the array and output it).

If the chrome devtools are open, performance is no longer an issue, because you're actually looking at the console (Which 99% of users wont do).

Source Show
◀ Wstecz