## 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面試