PHP traits

It may sound fancy, but it’s very simple and easy. trait sharable{ function foo(){ echo "foo\n"; } } class A{ use sharable; function bar(){ echo ... ...

简单的 async , await例子

var count = 0; var tick = () => { count++; setTimeout(() => { process.stdout.write('.'); if(count < 100) tick(); },100); } tick();//Init var getApple ... ...

玩玩 ES6 的 Promise 功能

Promise 是一个 Object, 它有两种形式: 1. Promise.resolve() 这样直接可以用. 2.new Promise(function(resolved,rejected){ … resolved(param) … }) 一个 Object 的形式, ... ...

第一手尝试 React Hook 的 useReducer

第一手尝试 React Hook 的 useReducer: import React, {useState,useEffect,useReducer} from 'react'; import ReactDOM from 'react-dom'; let histories = []; const ... ...

Higher Order Function in Javascript

It is a function to blueprint another functions: //Higher order function function multiplier(n){ return function(base){ return base*n; } } var doubler ... ...