Operators 13 Flashcards
Name two rules that make javascript operators easier to understand
- they mostly only work on primitive values
- they coerce operands to appropriate types. operators will rarely throw errors.
How does the plus operator work in javascript
in one of two ways
1. String Mode: if one operand is a string it will convert the other into a string and concatenates them and returns result
2. Number Mode: if none are strings it will assume numbers and add them and returns result
What are plain assignment operators used for?
To change or initialize storage locations
ex. const arr = [] or arr[0] = 1
What are the two types of operators in js?
Compound and logical
What is the difference between === and ==
== often coerces types, === will never and is only true if values are the same type
Use case for Object.is()?
comparing NaN to NaN
What are JavaScripts ordering operators?
< less than
> greater than
<= less than or equal to
>= greater than or equal to
these work for both numbers and strings (doesn’t work well for strings) and are based on strict equality