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 frutas = ['banana', 'maçã', 'abacaxi', 'mamão'] | |
frutas.forEach(fruta => console.log(`Eu preciso comer mais ${fruta}`)); | |
/* | |
Após executar: | |
Eu preciso comer mais banana | |
Eu preciso comer mais maçã | |
Eu preciso comer mais abacaxi | |
Eu preciso comer mais mamão |
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
class ProcessValidations { | |
/** | |
* Create concrete element | |
* @param {Array} validators | |
*/ | |
constructor(transaction) { | |
this.validators = [] | |
this.transaction = transaction | |
} |
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
/** | |
* REST PROPERTIES | |
* Using the REST operator "..." to extract properties from an object | |
* */ | |
const { website, ...moreInfo } = { | |
website: 'http://rec.jsday.com.br/', | |
day: 1, | |
month: 12, |
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 RE_DATE = /(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})/; | |
const matchObj = RE_DATE.exec('2018-12-01'); | |
console.log(matchObj); | |
/** | |
* [ | |
* 0: "2018-12-01", | |
* 1: "2018", |
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
/** | |
* ASYNCHRONOUS ITERATION | |
* - Specifies an asynchronous version of the "for-of"loop. | |
* - With the "for-await-of" loop allows you to iterate | |
* promises and return them on the order that they were called. | |
*/ | |
/** | |
* Let's imagine that we have 4 promises that they will |
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
/** | |
* EXPONENTIATION OPERATOR | |
* - Is the same as Math.pow() | |
* - Don't need to use the library Math | |
*/ | |
// using Math library | |
let newNumber1 = Math.pow(4, 2); | |
console.log(newNumber1); // 16 |
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
/** | |
* STRING PADDING | |
* - When you need a string to reach a specific length. | |
* - Two ways to add characters: padStart() and padEnd() | |
* - Basic usage: | |
* | |
* padStart(finalLength, padString) | |
* padEnd(finalLength, padString) | |
*/ |
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
/** | |
* PROMISE.PROTOTYPE.FINALLY() | |
* - Always executed | |
* - Allow to execute some code if the promise is successful or not successful | |
* - Similar to finally {} on synchronous code (try/catch/finally) | |
*/ | |
// example | |
fetch('https://randomuser.me/api/?results=1') | |
.then(data => data.json()) |
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 firstLine = '======================================================='; | |
const lastLine = firstLine; | |
const lenghtLines = firstLine.length; | |
let welcomeText = '⭐️ Hello World! Webpack + Babel! ⭐️'; | |
const lengthText = welcomeText.length; | |
const leftToComplete = lenghtLines - lengthText; | |
const halfComplete = leftToComplete/2; | |
welcomeText = welcomeText.padStart(lenghtLines-halfComplete, '~'); |