Socket IO Study

server.js var app = require("express")(); var http = require("http").Server(app); var io = require("socket.io")(http); app.get("/", (req, res) => { ... ...

Local HTTPS server

const express = require('express'); const path = require('path'); const https = require('https'); const http = require('http'); const fs = require('fs ... ...

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 ... ...