|
|
|
|
|
|\
First step to understand recursion requires understanding of operator precedence in JavaScript:
Operator precedence determines how operators are parsed concerning each other. Operators with higher precedence become the operands of operators with lower precedence. Source
To put it simply, if you have this code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In order to use property decorator we need to import | |
* built-in Reflect.metadata decorator | |
*/ | |
import 'reflect-metadata'; | |
/** | |
* 1. CLASS DECORATOR | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const button = document.getElementById('btn'); | |
function handleClick(clickEvent) { | |
/** React on click event */ | |
} | |
button.addEventListener('click', handleClick); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const API_URL = 'https://mysuperduperapp.com/api'; | |
function parseResponse(response) { | |
/** React on response event */ | |
return response.json(); | |
} | |
function handleResponse(data) { | |
/** React on successful parsing (job done) event */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleRequest(req, res) { | |
/** React on GET request */ | |
} | |
router.get('/api/topic/:id', handleRequest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Accessing files */ | |
fs.readFile('./index.html', handleDoneReading); | |
/** Dealing with streams */ | |
httpClient.get(API_URL) | |
.subsribe(handleObservableData); | |
/** Accessing database */ | |
User.findOne({ name: 'Igor' }, handleFoundData); |
OlderNewer