ES6 Promise & Async + Await

Create new Promise objects: const p = new Promise((resolve, reject) => { resolve("good"); }); const p2 = new Promise((resolv, reject) => { reject("bad ... ...

Useful Examples of ES6 Destructuring

Define a function to take configuration object as input: const func = ({a=1, b=2}) => { return a+b; } console.log(func({b:4})) //output: 5 Swap 2 v ... ...

How to clear Cookie data in chrome

Go to chrome://settings/content/cookies. type the domain name in the search box. Click delete. … Press control shift i (or command shift i on OS ... ...

Useful LeetCode Library

Convert an integer into an array of digits: var getDigitsArray = function(num){ if(num === 0) return [0]; var arr = []; while(num > 0){ var digit = nu ... ...

JavaScript里没有Associative Array

很多年来,我一直以为JavaScript里有Associative Array,而我也一直以为我每天在用的Associative Array,其实也只是Sugar Syntax. var arr; arr['a'] = 'apple'; arr['b'] = 'banana'; 其实它是一个Obje ... ...

Update SQL Table using CASE and WHEN

Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice ver ... ...