Joren Broekema
1 min readOct 22, 2019

--

Very interesting, did not know about this “trick” to treat, specifically, null and undefined, as the same (‘nothing’). Much safer than truesy/falsy comparison if you want to know if something equals a useless value (where 0 and ‘’ are not useless).

I dug a bit and found that airbnb base eslint best practices also added an ignore case to null for their ‘eqeqeq’ rule, so yay for that! https://github.com/airbnb/javascript/blob/57ff032b0740ba2a46af4bc40cf5638a3e62a365/packages/eslint-config-airbnb-base/rules/best-practices.js#L40

--

--

Joren Broekema
Joren Broekema

Written by Joren Broekema

Web developer, freelancer, trainer X -> @jorenbroekema

Responses (1)