I'll just briefly explain what that && does, for everyone not understanding what you mean:
&&
&& returns the value of the right-hand expression when both are truthy.
Same with ||: It returns the left-hand expression if it's truthy, or the right-hand one of the first one was falsey.
||
See the descriptions of the logical operators (and the examples) on MDN for more information.
So && can be used like 'when the left expression is truthy, return the right-hand (or run a function)'.
E.g.
condition && doThis()
And || can be used to provide a default value (or also run a function or something).
someVariable = someVariable || 0 someVariable || varIsFalsey()
Hope this was not too confusing.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'll just briefly explain what that
&&
does, for everyone not understanding what you mean:&&
returns the value of the right-hand expression when both are truthy.Same with
||
: It returns the left-hand expression if it's truthy, or the right-hand one of the first one was falsey.See the descriptions of the logical operators (and the examples) on MDN for more information.
So
&&
can be used like 'when the left expression is truthy, return the right-hand (or run a function)'.E.g.
And
||
can be used to provide a default value (or also run a function or something).Hope this was not too confusing.