來到新公司上班已經快一個月的時間,趁着空閒時間把本身這段時間的面試題進行一波總結,避免再次踩坑,有些問題仍是須要本身去查一下,有時間的話會把答案補全前端
class
.prototype
的新對象被建立。Foo
,並將 this
綁定到新建立的對象。new Foo
等同於 new
Foo
()
,也就是沒有指定參數列表,Foo
不帶任何參數調用的狀況。new
表達式的結果。若是構造函數沒有顯式返回一個對象,則使用步驟1建立的對象。(通常狀況下,構造函數不返回值,可是用戶能夠選擇主動返回對象,來覆蓋正常的對象建立步驟)//生成驗證碼 function verificationCode(){ let code = (Math.random()*100000000).toFixed(0) //console.log(msg,msg.length)) //長度不夠8位的補0 while(msg.length<8){ code = "0" + code console.log(code) } return code } function message(){ //使用對象存放驗證碼 let codes = {} //let arr = [] let index = 0 while(index < 1000){ let code = verificationCode() if(!codes[code]){ codes[code] = index index++ //arr.push(code) } } console.log(codes) //console.log(arr.length) }
最後推薦一篇文章前端面試考點多?看這些文章就夠了react