I love doing web development in Chrome and Safari, as they have excellent built-in develop tools. There is one catch that I need to keep reminding myself about however that I thought I would list here: The console is rendered just like the body is (sometimes).
This important note may seem a bit cryptic, but it can best be explained by taking a look at what happens when you ask the Chrome console to console.log() the value of various data types.
Imagine you had the following simple page:
You can see that we will be looping through this script 3 times and outputting 3 variables: an integer, an array, and an object.
Here are the results:
So what is going on here? If the console can render the variable directly (integer or string), it will render the variable as it was at the time of execution. If the variable is interpreted (array or object) then it will render the variable at it’s current state. If you can open the arrays in the console while he sleep is happening, you will notice them change over time. You would have expected the arrays to be:
but they were all [1,2,3] I hope this clears up some confusion!