Additional Operators
Explore the use of additional JavaScript operators such as +=, ++, --, &&, and ||. Understand their behavior in conditions and loops, how they affect values, and how to use shortcuts to write efficient, readable code. Learn how to correctly check for NaN values with Number.isNaN().
We'll cover the following...
We'll cover the following...
We will soon write conditions and loops. In these two control structures, a few operators come handy:
+=,-=,*=,/=,%=etc. are abbreviations for performing a mathematical operation on a variable.a += 1is the same as writinga = a + 1.++xincreases the value ofxby1, then returns the increased valuex++returns the original value ofx, then increases its value by1--xdecreases the value ofxby1, then returns the decreased valuex--returns the original value ofx, then decreases its value by1
++x and x++
I know the difference between ++x and x++ may not make sense to you right now. I argue that in most cases, it should not even make a difference as long as ...