-
Notifications
You must be signed in to change notification settings - Fork 1
01. Data Types, Declaration, Operators
idavidov13 edited this page Nov 28, 2023
·
7 revisions
- Object
- Primitive
- Number
- String
- Boolean
- Undefined
- Null
- Symbol
- BigInt
Type Conversion and Coercion(happens behind the scene - JS try to convert inputs in order to perform the operators)
- Number("input")
- String("input")
- Mathematic operations - +, -, *, /
- Assignment - +=, -=, *=, /=
- Iteration - ++, --
- Comparison - <, >, ===, ==, <=, >=, <>
- Equality - ===(comparisson of the type and value) or ==(comparisson only for the value) / !==(strict version) or !=(loose version)
- Concatenation - 'Ivan' + 'Davidov' = 'IvanDavidov'
age >=18 ? console.log('Whiskey') : console.log('Water')
I'm ${firstName}, a ${age} years old ${job}!
if(condition) { } else { };
- Falsy values - false, 0, '', undefined, null, NaN
switch(input) { case 'caseOne': some code; break; case 'caseTwo': some code; break; case 'caseThree': some code; break; case 'caseFour': some code; break; default: some code; }
- Match text by pattern
- Patterns are defined by special syntax, e.g.
[0-9]+ matches non-empty sequence of digits [A-Z][a-z]* matches a capital + small letters building RegExp
- \w – matches any word character (a-z, A-Z, 0-9, _)
- \W – matches any non-word character (the opposite of \w)
- \s – matches any white-space character
- \S – matches any non-white-space character (opposite of \s)
- \d – matches any decimal digit (0-9)
- \D – matches any non-decimal character (the opposite of \d)
-
- – matches the previous element zero or more times
-
- – matches the previous element one or more times
- ? – matches the previous element zero or one time
- {3} – matches the previous element exactly 3 times
- (subexpression) – captures the matched subexpression as a numbered group
- (?:subexpression) – defines a non-capturing group
- (?subexpression) – defines a named capturing group