Better console logging in Javascript
Yup. Debug all things. But there are better ways to do that than just console.log(). Let's get straight to the examples.
console.log with variable names
Instead of doing...
console.log("foo = "+foo);
console.log("bar = "+bar);
..you could do
console.log({foo, bar})
Get the whole call trace with console.trace
This will show the whole call trace for where the function was called from.
function secretFunc() { console.trace("Illuminati Confirmed"); }
function fbi() { secretFunc(); }
function cia() { secretFunc(); }
fbi();
cia();
console.table
foo = {"name": "XYZ", "car" : "Tesla"}
bar = {"name": "ABC", "car" : "Ford"}
console.table([foo, bar])
Track time with console.time
console.time("track-time")
let i = 1
while (i < 10000000) { i++; }
console.timeEnd("track-time")
Happy hacking