原创 ES2017 Async

async 函數 用於實現異步執行事件 返回值:一個Promise對象,這個Promise對象當 async 函數開始執行時被創建。 當 async 函數返回值時, Promise 的 resolve 方法會傳遞這個值。 當 async

原创 ES6 Promise

參考https://pouchdb.com/2015/05/1...https://developer.mozilla.org...http://es6.ruanyifeng.com/#do... Promises 是一種編寫異步代碼的方法

原创 如何在代碼運行時判斷定時器的狀態

參考:https://stackoverflow.com/que... 問題:當前模塊只需要一個定時器。但是如果有多個地方調用getData()會出現多個定時器 private timer = null; private setTi

原创 翻譯:Taming the asynchronous beast with ES7

原文:https://pouchdb.com/2015/03/0... PouchDB最棘手的方面之一是它的API是異步的。在Stack Overflow、Github和IRC上,我看到了不少困惑的問題,而且這些問題通常是由對callbac

原创 node path 學習

path 模塊 提供用於處理文件路徑和目錄路徑的實用工具 使用方法:const path = require('path'); path的屬性與方法 path.dirname(path) 返回 path 的目錄名 Windows

原创 node os方法和使用示例

os(操作系統) 提供了操作系統相關的實用方法 使用方法: const os = require('os'); os提供的方法和使用示例 os.type() 以字符串的形式返回操作系統的名字 eg: > os.type(

原创 nodejs Events 學習筆記

EventEmitter 類 const EventEmitter = require('events'); 'newListener' 事件 當新增監聽器時,在新的監聽器被添加到其內部監聽器數組之前觸發 'removeListen

原创 js中this的“終極三問”

this是什麼? this 本質是一個綁定, 在函數被調用時建立。它的指向是完全由函數被調用的調用點來決定的。 function baz() { console.log(this);//因爲baz函數的調用點在全局作用域,所以th

原创 js變量提升

Refer: https://developer.mozilla.org/zh-CN/docs/Glossary/Hoisting https://www.zhihu.com/question/19636194 https://develo