Avoid to use var because it has global scope and can cause hoisting problems.
The name of the variable must have meaning and if contains multiple words camelCase must be used
The name or the variable must contain only letters, digitis, or the symbols $ and _
The first character must not be a digit
There are reserved words that cannot be used when naming variables
The + operator is used to sum two values, but it can also be used to concatenate two strings.
Returns the remainder of two operand.
= compares the equity of two values without considering the type, while the === takes in consideration the type.
When the expected output type should be a number but is not
Increment: ++
Decrement: --
When prefixing, the variable is incremented/decremented first and then the expression is evaluated using the new value of the variable.
When post-fixing, the expression is evaluated and then the variable is incremented/decremented.
Determines the order in which the operator is processed
console.log()
Concatenates the two strings.
Objects
"" and '' are used to create string literals, while the `` are used to create template strings.
String Interplation
``
string = `I am a ${typeof string}`;
slice(start, end) extracts a part of a string and returns the extracted part in a new string.
substring(start, end) is similar to slice(), but the difference is that start and end values less than 0 are treated as 0
substr(start, length) extracts a new string according to the length defined in the second property
Or ||
Not !
And &&
== equal to
=== equal type and value
!= not equal to
!== the value and type are not equals
< less than
> greater than
>= greater or equal than
<= less or equal than
Truly values are values evaluated to True in a Boolean Context
Falsy values are values evaluated to False in a Boolean Context
Undefined, Null, NaN, 0, ""
conditionals are blocks of code that only run if the condition is met
if(condition){
//Run the code
}else{
//Run the code
}
switch(expression){
case(valueX):
//Run the Code
break;
case(valueY):
//Run the Code
continue;
}
expression ? do this : do that
Nesting is writing code inside of some other code like a function or a condition
Functions are uselful to simplify repetitive tasks
funcName(params)
Anonymous functions are functions that have no name.
The scope is related to where the variable is available. If the variable is created whithin a function, it will only be available "inside" the function.
The return values are the values that a function returns when it has completed.
Arrow functions are a simplified and concise way to create functions.