Operators 13 Flashcards

1
Q

Name two rules that make javascript operators easier to understand

A
  1. they mostly only work on primitive values
  2. they coerce operands to appropriate types. operators will rarely throw errors.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the plus operator work in javascript

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are plain assignment operators used for?

A

To change or initialize storage locations
ex. const arr = [] or arr[0] = 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the two types of operators in js?

A

Compound and logical

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between === and ==

A

== often coerces types, === will never and is only true if values are the same type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Use case for Object.is()?

A

comparing NaN to NaN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are JavaScripts ordering operators?

A

< 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly