cookie
// 匹配 cookie 正则表达式
function read(name) {
var match = document.cookie.match(new RegExp('(^|;\s*)(' + name + ')=([^;*'));
return (match ? decodeURIComponent(match[3]) : null);
},
promise组织形式
// 封装promise
var promise = Promise.resolve(target) // target 可以是promise对象也可以不是
// 等价于
var promise = new Promise(resolve => resolve(target))
var promise = Promise.reject(target)
// 等价于
var promise = new Promise((resolve, reject) => reject(target))