Dev utterings   Whoami

Console logging tricks in es6

Console logging tricks in es6…

Easier tracing?

// eg:
console.log(x);

// Solution: Wrap in object syntax
console.log({ x });

// #=> { x: .... }

Arrow function?

// eg:
x => someFunction(x);

// Solution: Due to console.log always returning undefined, we can throw a logical operator after it to return our original function
x => console.log(x) || someFunction(x);
// or as above
x => console.log({ x }) || someFunction(x);

Written on Sep 5, 2018.