DEV Community

Discussion on: Like `console.log` But Better

Collapse
 
easilybaffled profile image
Danny Michaelis

Great post, Leira! I love seeing more people use styles in their logging. I'd like to add one more to your list, console.tap. It's one of my own creation, made to solve the fact that console.log returns undefined. Instead tap returns the first value you passed in. Imagine trying to log the result of the filter:

['1', '2', 'zero' , 3, 4, 5]
    .map(parseNumbers)
    .filter(removeEvens)
    .reduce(( acc, v ) => Math.max(acc, v))
Collapse
 
leirasanchez profile image
Leira Sánchez

I will definitely check it out. Thank you!

Collapse
 
bashunaimiroy profile image
Bashu Naimi-Roy

This is fascinating and addresses a frequently encountered awkwardness of console.log, thank you! I'm going to start using this a lot