1 min readApr 8, 2017
Awesome tips! I’ve been using most of these for a little while now. Mostly trying to write code without any if statements.
Another clever use case of the || operator is making sure a deeply nested value exists.
// Arbitrary example
( ( ( data || {} ).prop || {} ).nestedProp || [] ).length
&& ( const filtered = data.prop.nestedProp.filter(doFilter) )
&& filtered.length
? doSomethingWithFilteredData(filtered)
: doSomethingElse()I like the comma idea, going to start using it!




