JavaScript Fundamentals - Part 2
Last Updated on: August 10, 2021 pm
JavaScript Fundamentals - Part 2
Activate Strict Mode
Strict mode creates visible errors in developer console, where in other situations without strict mode the code will fail silently.
Function Declaration vs. Expression
Declaration
1 |
|
Can call the function before the it is defined.
Expression
1 |
|
Cannot access the function before it is defined.
Arrow Function
For simple one-line function:
1 |
|
For multi-line function:
1 |
|
Array Operations
Unshift
['Micheal', 'Steven']
—> ['John', 'Micheal', 'Steven']
1 |
|
push
['Micheal', 'Steven']
—> [ 'Micheal', 'Steven', 'John']
1 |
|
Returns the length of the new Array.
pop & shift
pop - pop the last one
shift - pop the first one
indexOf
If exist - return the index
If not exist - return -1
includes
Strict Mode!!
return a boolean value whether the element exists in the array
Objects
1 |
|
Object Methods
1 |
|