So, first up the or (||)
operator:
a || b === a if a is truthy, otherwise b
So the or
operator isn't strictly useful for boolean types. For example, you could set a default value for data like
function makePerson(name, age) {
return { name: name, age: age || 0 }
}
Next, the not (!)
operator:
!a === false if a is truthy, true otherwise
So note that the !
operator strictly provides boolean outputs.
So with your example,
Email||Password||Song
will be Email
if truthy, then Password
if truthy, and finally Song
!Email||!Password||!Song
is going to end up evaluating to something like
false||false||true
or
true||false||false
etc. By adding in the unary not, you're effectively casting all your inputs to booleans, and the output of the or operator is the type of its inputs.