有贊2018年9月秋招一面

一面:javascript

現場擼代碼:css

題目:input  arr=[2,7,8,1,-6,-7,15]    target=9java

           output 全部兩數相加等於target的數值對:[[2,7],[1,8],[-6,15]] react

分析:以數組值爲對象的key,能夠當即查找到,提升時間複雜度css3

           obj={key:true}web

// 捨棄空間換時間,時間複雜度爲o(n)
function sumArr(arr,target){
    let obj={};
    let result=[];
    for(item of arr){
        let temp = target-item;
        if(obj[temp] === true){
            result.push([temp,item]);
        }
        // 重複的狀況
        if(!obj.item){
            obj[item]=true;
        }
    }
    return result
}

console.log(sumArr([2,0,4,2,7,8,6,4,1,-6,-7,15],8));

 

 

提問canvas

1.js的基本類型,引用類型,如何判斷?跨域

5大基本類型:number,string,boolean,undefined,null
3大引用類型:Function,Array,Object
判斷方法:
(1)typeof()
typeof(NaN)//number
typeof(undefined) //undefined 缺點:typeof(null|[]|{}|new Data()|RegExp()) //object (2)instanceof(A,B) 判斷A是不是B的實例,檢測的是原型 [] instanceof Array //true {} instanceof Object // true 缺點: []|new Date() instanceof Object //true 注意: []._proto_指向Array.prototype;Array.prototype._proto_又指向了Object.prototype ES5方法:arr.isArray() (3)constructor 當函數被定義時,會被添加prototype原型,而後在prototype上添加constructor屬性,並讓其指向函數的引用 ''.constructor == String //true; new Number(1)|true|new Date()|[]均可以準確判斷 缺點: null,undefined沒法判斷 constructor是不穩定的,重寫prototype後,原有的引用會丟失 (4)toString Object的原型方法,默認返回[object Xxx];Xxx爲對象的類型 Object.prototype.toString.call('') //[object String] Object.prototype.toString.call(null) //[object Null] Object.prototype.toString.call(undefined) //[object Undefined]

  

2.http狀態碼數組

2XX
200:請求成功
201:已建立新的資源
202:已接受
203:非受權信息
204:無內容
205:重置內容

3XX
300:請求的資源包括多個位置,可返回地址選擇列表
301:資源長久移動,會返回新的url,瀏覽器會自動定向到新的url
302:資源臨時移動,客戶端仍是用原有的url
304:所請求的資源未修改,客戶端緩存了訪問的資源,因此服務器不會返回
305:所請求資源必須經過代理訪問

4XX
400:客戶端請求語法錯誤
401:權限問題
403:服務端拒絕執行
404:找不到資源,路徑不對
405:請求中的方法被禁止
407:使用代理受權
408:請求時間過長

5XX
500:服務器內部錯誤
501:服務器不支持請求功能
502:充當網關或代理服務器接收到無效請求
503:維護,或超載,服務器暫時沒法處理請求
504:請求超時

3.跨域問題,如何實現的?瀏覽器

 

4.數據結構鐘有哪些二叉平衡樹?b+,b-樹的區別?紅黑樹?

 

5.動畫了解嗎? 

css3:animation,transition+transfrom
animation-name 規定須要綁定到選擇器的 keyframe 名稱。。
animation-duration 規定完成動畫所花費的時間,以秒或毫秒
animation-timing-function 規定動畫的速度曲線。
animation-delay 規定在動畫開始以前的延遲。
animation-iteration-count 規定動畫應該播放的次數。
animation-direction 規定是否應該輪流反向播放動畫。
js:settimeout(),setinterval()
h5的canvas,webGL
4.瀏覽器定時輪詢的接口:requestAnimationFrame
// 頁面返回頂部

toScrollTop() {   window.requestAnimationFrame(
function fn() {
//IE 非IE   const scrollTop
= document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;   const speed = Math.floor(-scrollTop / 8);   document.documentElement.scrollTop = document.body.scrollTop = scrollTop + speed;   this.returningToTop = true;   if (scrollTop > 0) {
// 不斷輪詢     window.requestAnimationFrame(fn.bind(
this));   } else {     this.returningToTop = false;   }   }.bind(this)); }
//番外
offsetHeight = content.height+border.height
clientheight = content.height
scrollHeight = 滾動的高度

 

6.redus狀態管理?

 

7.react生命週期?

相關文章
相關標籤/搜索