## Promise简单版
```
const PENDING = 'PENDING';
const RESOLVED = 'RESOLVED';
const REJECTED = 'REJECTED';
function Promise(executor) {
const resolve = value => {
this.status = RESOLVED;
this.value = value;
this.onResolvedCallback && this.onResolvedCallback();
}
const reject = value => {
this.status = REJECTED;
this.value = value;
this.onRejectedCallback();
}
this.status = PENDING;
this.value = undefined;
this.onResolvedCallback = null;
this.onRejectedCallback = null;
executor(resolve, reject);
}
Promise.prototype.then = function (onResolved, onRejected) {
if (this.status == PENDING) {
this.onResolvedCallback = () => {
onResolved(this.value);
}
this.onRejectedCallback = () => {
onRejected(this.value);
}
}
if (this.status == RESOLVED) {
onResolved(this.value);
}
if (this.status == REJECTED) {
onRejected(this.value);
}
}
```
- 初级前端题
- 必会
- http协议
- 跨域
- cookie与storage
- 移动端问题
- 性能优化
- Vue全家桶
- 有哪些常用的es6语法?
- 项目
- 闭包
- JSON
- 数据类型与运算
- 数组
- DOM
- 字符串
- 要会
- async与await
- 正则
- this
- 数据加密
- 实时获取数据
- 原生ajax
- 异步打印
- css相关
- 杂七杂八
- webpack
- 一般
- mvvm模式
- 异步请求
- XSS
- 其他dom问题
- 冷门
- 浏览器缓存机制
- 新
- 浏览器事件轮询
- Promise
- 树的深度优先与广度优先
- 拷贝
- 继承
- Vue
- 跨域
- 排序
- 浏览器
- 浏览器入门
- 浏览器内核知识
- 浏览器渲染原理
- 浏览器性能调优
- 自动化构建
- 字符编码
- git
- 一些题目
- 其他
- 逻辑思维题
- 互联网公司招聘信息如何阅读
- bat面试