Promise 從入門到自定義 系列一(準備階段)

2021-10-07 04:21:23 字數 1217 閱讀 3402

function fn() 

const fn = new fn() // fn是建構函式,fn是例項物件(簡稱物件)

console.log(fn.prototype) // fn是函式物件

fn.bind({}) // 呼叫fn函式物件的bind方法

$('#test') // jquery函式

$.get('/test') // 呼叫jquery函式物件的get方法

const arr=[1,3,5]

arr.foreach(item => )

console.log('foreach()後面') // 後執行

settimeout(()=>,0)

console.log('settimeout()後面') // 先執行

error: 所有錯誤的父型別

referenceerror: 引用的變數不存在

console.log(a) // uncaught referenceerror: a is not defined
typeerror: 資料型別不正確的錯誤

let b=null

// uncaught typeerror: cannot read property 'xx' of null

console.log(b.xx)

rangeerror: 資料值不在其所允許的範圍內

// uncaught rangeerror: maximum call stack size exceeded

function fn()

fn()

syntaxerror: 語法錯誤

const c="""" // uncaught syntaxerror: unexpected string
捕獲錯誤: try…catch

如果沒有捕獲錯誤,則錯誤之後的**不會執行

try  catch (error)
丟擲錯誤:throw error

function something()  else 

}// 捕獲異常

try catch(error)

stack屬性:函式呼叫棧記錄資訊

自定義實現Promise

promise是很重要的知識點,必須牢記於心,下面是自定義實現的promise class mypromise catch error 成功時 resolve value 失敗時 reject reason then onresolve,onrejected p.then then value co...

自定義標籤入門

bodytagsupport執行順序 載bodytagsupport類的方法 編寫標籤對應的實現類時,需要過載bodytagsupport類幾個方法 dostarttag setbodycontent doinitbody doafterbody doendtag 他們執行順序如下 dostartt...

自定義View之Android座標系

自定義控制項的繪製離不開android座標系。本篇詳細記錄android座標系。android座標系 如上圖所示,方框代表的是手機螢幕,水平向右為x軸,垂直向下為y軸,y軸的座標越向下越大,座標系原點是螢幕左上角。上 釋了螢幕中的view獲取四個邊距的方法。子view的四個方法獲得的值是相對于父vi...