See this jsbin where, to answer another question, I build an array-like object :
function myCollection() {
var items = [], r = {}
function myPush(value){
value += 'bar'
r[items.length]=value;
items.push(value)
}
Object.defineProperty(r, "splice", {value:[].splice});
Object.defineProperty(r, "slice", {value:[].slice});
Object.defineProperty(r, "length", {
get : function(){ return items.length}
});
Object.defineProperty(r, "myPush", {value:myPush});
return r;
}
var fooCollection = myCollection();
fooCollection.myPush('foo');
console.log(fooCollection); // logs ["foobar"]
fooCollection.myPush('Ba');
console.log(fooCollection); // logs ["foobar", "Babar"]
fooCollection.myPush('wzouing');
console.log(fooCollection.slice(-2)); //logs ["Babar", "wzouingbar"]
console.log(fooCollection[1]); // logs Babar
If you hit the Run with JS button on Chromium with the console open, you get this :
The very curious thing is that if you hit the button while the console is closed you get this (you see it after having reopened the console, of course) :
Is that a known bug ? A feature ? A grey zone ? Is there a workaround ?
*Note : sometimes, on Chrome/linux (not Chromium) I get something weirder : existing logs are changed when closing and reopening the console. They can go from the array like form to the folded form. *