Reputation: 79268
Wondering if chrome console.log
allows you to go back and rewrite existing console.log output, like you can do in Node.js. I know you can do colors in the chrome console, but not sure about editing existing text. Would like to try adding a progress bar such as:
I'm getting this:
Upvotes: 2
Views: 1774
Reputation: 177594
Try calling console.clear
(chrome, MDN) in a loop. This works as long as you have ‘preserve log’ turned off. It flickers a bit for me in Chrome’s console, but such is life (it's actually great in Firefox).
delay=t=>new Promise(resolve=>setTimeout(resolve,t));
// the stack snippets console emulator doesn't seem
// to work if the very first call is clear.
console.log();
(async()=>{
for(i=0;i<25;i++){
console.clear();
console.log('*'.repeat(i));
await delay(100);
}
})()
Upvotes: 3