Return to site

JS TIP: R.isNil() checks null AND undefined

ยท fullstack

โš ๏ธ Be careful when replacing classic ===๐’๐’–๐’๐’ with Ramda APi ๐‘น.๐’Š๐’”๐‘ต๐’Š๐’() because it could mislead โ†ฉ๏ธ your business logic.

Imagine you declare an object but does not assign it.

๐’๐’†๐’• ๐’Ž๐’š๐‘ถ๐’“๐’…๐’†๐’“;

And later๐Ÿ•‘ in the code you set it to null when there is an errorโŒ:

And somewhere๐ŸŽฏ in the code you check with ===๐ง๐ฎ๐ฅ๐ฅ, your order:

if you replace it with ๐‘น.๐’Š๐’”๐‘ต๐’Š๐’() of Ramda API, you will take the ๐’๐’–๐’๐’ values AND the ๐’–๐’๐’…๐’†๐’‡๐’Š๐’๐’†๐’… values.

Maybe you process the ๐’–๐’๐’…๐’†๐’‡๐’Š๐’๐’†๐’… later in the business implementation, in such case, the ๐‘น.๐’Š๐’”๐‘ต๐’Š๐’() will mislead๐Ÿ”ฅ your intent.

#javascript #programming #nullcheck #ramda

 

broken image