
Schemetastic
Freebies
Soon
Posts about Front-end and +
In the previous part of this series I talked about how
you can shorten your conditionals with truthy and falsy
values. So if you haven’t read that one I would
recommend that you do cause this is a continuation, Link
here! Probably in some occasion you have seen pieces of
JS code from other programmers and suddenly you saw
something like a question mark (?) and then a colon (:)
and maybe you didn’t knew what was going on there, I
remember this happened to me and I felt a little
confused, but after I learned this I realized how handy
and useful it is in so many situations.
In the previous part of this series, I talked about how
you can shorten your conditionals with truthy and falsy
values. If you haven’t read that one I would recommend
that you do it because this is a continuation, Link
here! Probably you have realized of how hard and
confusing can it be to read a long conditional… Let me
give you a few examples of that, and later in the post
I’ll give you better solutions to them:
I know that when you are working with conditions in JS
very easily you could end up with an if statement with a
lot of AND’s (&&) but also a lot of OR’s (||),
this can lead to a long condition that can be hard to
read and also bring some complications to your code
(more than the ones that probably already have), that’s
why in this part of the series and the next one I’ll
give you a few tips to make conditionals shorter and
easier to read.
What are function declarations and function expressions?
🔗Basically you can define functions with the function
keyword at least in two ways: with a Function
declaration which starts with the function keyword, then
the name of the function, then the arguments (), and
finally the statements{}; Also as a Function expression
which can be stored in a variable, a constant or passed
through a function argument, the syntax is quite similar
to a function declaration, however, a function
expression can be anonymous or be named.