loading...
Cover image for " ! " Not Operator

" ! " Not Operator

giandodev profile image GiandoDev ・1 min read

The not operator avoid us from writing the else statemet like in this example:
Alt Text
In the example above we ask with our if(!apples) : if apples is falsey run this argument, so we avoid to write this:
Alt Text
Another occasion where it can be very useful is when we need to convert a Truthy and Falsey values in True and False.
Alt Text
In the example above we convert first apples(falsey) into apples(true) with our first not operator(!), with the second not operator we convert our apples(true) in apples(false), then our apples(falsey) has become apples(false). The opposite happened for our apples(truthy).

Posted on by:

giandodev profile

GiandoDev

@giandodev

Hi, I am Giandomenico. I love to learn new stuff and solve problems.

Discussion

markdown guide