I have this simple JavaScript code. I have a problem; the first time I launch the page the script I do not have the desired behavior, but when I refresh the page I have the right info.
Honestly I have no idea why I have this concern.
I wanted to share this code in a jsfiddle but the problem does not appear. The problem is present on Chrome and Firefox but not on Edge
//AJOUT TABLEAU FIN
var tableau = [1, 2];
tableau.push(3);
tableau.push(4, ['a', 'b', 'c']);
console.log('ajout fin:', tableau);
//AJOUT DEBUT TABLEAU
tableau.unshift('ajout', 'au', 'debut');
console.log('ajout debut :', tableau);
//SUPPRESSION PREMIER ELEMENT
tableau.shift();
console.log('suppression premier element:', tableau);
//SUPPRESSION DERNIER ELEMENT
tableau.pop();
console.log('suppression dernier element:', tableau);
The first part is when I launch the direct script via its URL, the second part is when I update the page or when I arrive on the page by clicking on a link from another page before.
I know it's really strange and I would have like to know if there was an answer