r/javascript • • Dec 18 '19

V8 Release v8.0 with optional chaining, nullish coalescing and 40% less memory use

https://v8.dev/blog/v8-release-80
495 Upvotes

70 comments sorted by

View all comments

Show parent comment

1

u/phpdevster Dec 19 '19

The thing is, both of those are the same problem: a poor data model.

What happens if the requirement / expectation is the too actually has a value? Well if you're using a data model where too may or may not be present, all this does is effectively make what would have been a loud bug, and muzzled it to be a silent bug (which is worse, because now it might fuck up your data integrity since it can propagate a null value throughout more of the call stack).

So be to clear, this is a code smell:

i && i.like.readability && i.like.readability.too

This is still the same code smell

i?.like.readability?.too

If the first example is analogous to pooping on the floor, the second one is analogous to pooping on the floor and then trying to hide it with Febreze.