Why does the console.log function with GOOGLE CHROME displays the final version of a variable even if the it has not been changed yet? For example :
var a = 1
console.log(a) //console from chrome should display '1'
a = 2
console.log(a) //console from chrome should now display '2'
But actually it displays :
'2'
'2'
By the way my JS script use used in a HTML file, and that's this HTML file that I'm opening with chrome.
EDIT Sorry, I wanted to simplify the problem so I used an exmample with this simple integer variable, but actually I have this problem with a 2 dimensional array. Here's my code :
var tab = new Array(8).fill(0)
for (x=0;x<8;x++) {tab[x] = new Array(8).fill(0)}
console.log(tab)
tab[0][0] = 2
console.log(tab)
And now with this type of variable (a 2 dimensional array, a 1 dimensional one seems to work fine) I have the same display for both 'console.log' instructions, which is a 8x8 array with a 2 on the top right corner