Add this to your devtools console.
var oldEPD = Event.prototype.preventDefault;
Event.prototype.preventDefault = function() {
debugger;
| /** | |
| * API Service | |
| * @async | |
| * @returns {Promise<Object>} | |
| */ | |
| async function Service() { | |
| let response = await fetch('/api.json'); | |
| if (response.ok) return await response.json(); | |
| throw new Error(response.statusText); | |
| } |
| RenderModal(settings) { | |
| const { modalIsOpen, targetDomNode } = settings; | |
| const closeModal = () => { | |
| this.RenderModal( | |
| Object.assign(settings, { | |
| modalIsOpen: false | |
| }) | |
| ); | |
| }; |
| let members = new Map([["Sam", 56], ["Sandy", 86]]); | |
| let youngestMemberAge = Math.min(...members.values()) // 86 | |
| let Over60s = new Map( | |
| [...members].filter(([name, age]) => 60 < age) | |
| ); | |
| let Over60sUserNames = new Map( | |
| [...members].map(([name, age]) => { |
| /** | |
| * @param {boolean} condition | |
| * @param {string} msg | |
| */ | |
| export function assert (condition, msg) { | |
| if (!condition) throw new Error(`[assert error] ${msg}`) | |
| } |
Arrow functions create a concise expression that encapsulates a small piece of functionality. Additionally, arrows retain the scope of the caller inside the function eliminating the need of self = this.
// const multiply = function(x,y) {
| // Will take 1000ms total! | |
| async function series() { | |
| await wait(500); | |
| await wait(500); | |
| return "done!"; | |
| } | |
| // Would take only 500ms total! | |
| async function parallel() { | |
| const wait1 = wait(500); |
Source repo: xxx
Dev Site: http://example.com
Uat site: http://example.com
| console[console.info ? 'info' : 'log'] ("Hello world") |
A short summary of ES6 features and their ES5 equivalents.
Access in-depth ES6 articles here.
Table of contents