Study/Coding

Types and Operators

Haayany 2020. 2. 7. 17:11

Operator: typeof

show the type of the operand

Numbers

- subtract
+ add
* multiply
/ divide
% remainder
++ increment (add 1)
-- decrement (subtract 1)
** exponentiation

common increment bug(also works in decrement)

Number precision bug

number operator shortcut

price = price - 5;
price -= price; are same

Operator precedence

Precedence Operator type Associativity Individual Operators
21 Grouping n/a ( … ) parenthesis
20 Member Access left-to-right … . …
Computed Member Access left-to-right … [ … ]
new (with argument list) n/a new … ( … )
Function Call left-to-right … (  )
Optional chaining left-to-right ?.
19 new (without argument list) right-to-left new …
18 Postfix Increment n/a … ++
Postfix Decrement … --
17 Logical NOT right-to-left ! …
Bitwise NOT ~ …
Unary Plus + …
Unary Negation - …
Prefix Increment ++ …
Prefix Decrement -- …
typeof typeof …
void void …
delete delete …
await await …
16 Exponentiation right-to-left … ** …
15 Multiplication left-to-right … * …
Division … / …
Remainder … % …
14 Addition left-to-right … + …
Subtraction … - …
13 Bitwise Left Shift left-to-right … << …
Bitwise Right Shift … >> …
Bitwise Unsigned Right Shift … >>> …
12 Less Than left-to-right … < …
Less Than Or Equal … <= …
Greater Than … > …
Greater Than Or Equal … >= …
in … in …
instanceof … instanceof …
11 Equality left-to-right … == …
Inequality … != …
Strict Equality … === …
Strict Inequality … !== …
10 Bitwise AND left-to-right … & …
9 Bitwise XOR left-to-right … ^ …
8 Bitwise OR left-to-right … | …
7 Nullish coalescing operator left-to-right … ?? …
6 Logical AND left-to-right … && …
5 Logical OR left-to-right … || …
4 Conditional right-to-left … ? … : …
3 Assignment right-to-left … = …
… += …
… -= …
… **= …
… *= …
… /= …
… %= …
… <<= …
… >>= …
… >>>= …
… &= …
… ^= …
… |= …
2 yield right-to-left yield …
yield* yield* …
1 Comma / Sequence left-to-right … , …

Strings (text)

3 styles of quotes: "", '', ``

*if you want to use special characters as Strings, use escape notation. ( \)

Using ` (backtick) 

 

 

Manipulating strings
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#Methods

using methods

Converting Between Types

using methods ( toString , Number.parseFloat("string")

String
number
also number, it doesn't show A

Boolean Variable

true / false
!:  not

true, as not false is true


null and undefined

undefined: not initialized variable, assigned by JS

null: wipe out the variable's value, assigned by developers(manually)

*always use null!!!

 

Objects and Symbols

objects created by { ... }

[object object]
Jim

'Study > Coding' 카테고리의 다른 글

Objects  (0) 2020.02.17
Functions  (0) 2020.02.12
Program Flow  (0) 2020.02.12
Variables and Constants  (0) 2020.02.07
File의 두가지 형식, Binary / Text  (0) 2018.11.02