console.log() and google chrome
- by Lorenzo C
I'm testing a library and I use console.log() function to visualyze values.
There is a strange behaviour of Google Chrome (in other browser like Firefox it doesn't happend).
If I try to store strings in Array object when I log them, sometimes values appears undefined.
Code example (item.name is a string)
var arrayItemsSearch = [item.name];
var itemRedrawName = [item.name];
console.log("arrayItemsSearch: ", arrayItemsSearch);
console.log("itemRedrawName: ", itemRedrawName);
Firefox output is correct
arrayItemsSearch: ["elem[0]"]
itemRedrawName: ["elem[0]"]
Chrome output is not correct
arrayItemsSearch: [undefined × 1]
itemRedrawName: ["elem[0]"]
Is this a Chrome bug? Or is this beacuse in Javascript strings are immutable objects and so something that I don't understand goes wrong?