Just wanted to try out some of the new features after I had read a post ES8 was Released and here are its Main New Features 🔥
Here I will post examples using some ES8
features
Just wanted to try out some of the new features after I had read a post ES8 was Released and here are its Main New Features 🔥
Here I will post examples using some ES8
features
// padStart and padEnd | |
var now = new Date(); | |
console.log(`${now.getHours().toString().padStart(2,"0")}:${now.getMinutes().toString().padStart(2,"0")}`) | |
/* Output: | |
09:41 (or something simular) | |
*/ | |
// Object.values | |
var objectTypes = {} | |
Object.values(window).map(obj => { | |
const type = typeof obj; | |
if (typeof objectTypes[type] != 'undefined') { | |
objectTypes[type] = objectTypes[type]+1; | |
} else { | |
objectTypes[type]=0; | |
} | |
}) | |
var output = `The values of the keys found in the window object of the page "${document.location}" has:` | |
Object.keys(objectTypes).map(type => { | |
output+=`\n"${type}" found ${objectTypes[type]} times` | |
}) | |
console.log(output) | |
/* OUTPUT: | |
The values of the keys found in the window object of the page "https://gist.github.com/" has: | |
"function" found 58 times | |
"object" found 142 times | |
"undefined" found 1 times | |
"number" found 13 times | |
"boolean" found 1 times | |
"string" found 5 times | |
*/ |