Created
January 29, 2020 11:08
-
-
Save ger86/549679e42d363667834009a3498fc66c to your computer and use it in GitHub Desktop.
JS: Novedades 2020
This file contains hidden or 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
/**************************************************************** | |
* | |
* | |
* 🆕🆕🆕 Nuevas características de Javascript en 2020 | |
* | |
* | |
*****************************************************************/ | |
/** | |
* | |
* 1️⃣ Optional chaining | |
*/ | |
const person = { | |
name: 'Gerardo', | |
age: 19, | |
company: 'Latte and Code', | |
}; | |
console.log(person?.contactInfo?.telephone); // undefined | |
/** | |
* | |
* 2️⃣ Nullish coalescing operator | |
* | |
*/ | |
const zero = 0; | |
const nullValue = null; | |
console.log(zero || 1); // 1 | |
console.log(zero ?? 1); // 0 | |
console.log(nullValue ?? 1) // 1 | |
/** | |
* | |
* 3️⃣ Numeric separators | |
* | |
*/ | |
const aBillion = 1_000_000_000; // 1000000000 | |
const otherAmount = 1_234_567.89 // 1234567.89 | |
/** | |
* | |
* 4️⃣ Dynamic import | |
* | |
*/ | |
// Promise style | |
import('/modules/my-module.js') | |
.then((module) => { | |
// Do something with the module. | |
}); | |
// Async-await style | |
let module = await import('/modules/my-module.js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment