Posts

Showing posts from May, 2017

Use the conditionals properly in JS

Hi Guys, I know I haven't been writting too much (none I guess) I'm sorry for that, but I've been learning new stuff :D Today I want to share with you how to take advantage of the conditionals in JS, but first we need to understand how they work: //OR You might know that in JS the OR operator is represented by double pipes: || but, is it really returning a boolean value? well, the answer to that question is...NO, JS uses type conversion, it converts a type to boolean but just in certain contexts, take the following code snippet as example: Basically the OR operator seeks for a truly value from left to right, once it found it, it returns that value, if the conditional is used on a loop/conditional context, then JS will evaluate its truly value, if not, it will evaluate the real value. //AND The AND operator ( && ) it's used to evalue a truly condition, but I guess you already know that, and knowing how JS evaluates the conditionals depending on th