面試題及答案

1.CSS優先級算法如何計算css

2.CSS盒子模型css3

3.new操做符具體幹了什麼呢web

4.DOM操做——怎樣添加、移除、複製、建立和查找節點算法

5.js有幾種數據類型,分別是什麼數組

6.js如何判斷一個數組app

7.如何經過指定名稱建立一個元素ide

 

8.Jquery中,如何給動態添加的元素綁定事件性能

 

9.如何獲取元素的屬性   如 <a href=’www.baidu.com’>  獲取href的值優化

 

10.form表單提交的必須條件是什麼spa

 

11.  寫出下面報錯語句的可能緣由

1Uncaught SyntaxError: Unexpected token )  

 

(2)Uncaught SyntaxError: Unexpected identifier

 

(3) Unexpected end of input

 

  1. 常遇到的AjaxStatus Code有哪幾種,分別表明什麼意思

 

13.請寫一個方法去除數組中的某個指定元素。

arr = [1,2,3,4,5,6]  remove(arr,6) = [1,2,3,4,5]

function remove(arr,value){

 

Your Code...

 

Return arr;

}

 

 

答案 

 

1題:

    

    * 優先級就近原則,同權重狀況下樣式定義最近者爲準。

    * 已最後載入的樣式爲準。

    優先級爲:

    同權重: 內聯樣式表(標籤內部)> 嵌入樣式表(當前文件中)> 外部樣式表(外部文件中)。

    !important > id > class > tag

    important 比 內聯優先級高

 

2題:

HTML中有句話:every element in web design is a rectangular box!

盒子包括: content -> padding -> border -> margin

 

css3 box-sizing: border-box 時,width: content + padding + border

 

3題:

var obj = {};obj.__proto__ = fun.prototype;fun.call(obj);

 

4題:

建立: createDocumentFragment (一般會起到優化性能的做用)createELement (建立一個具體的元素)createTextNode (建立一個文本節點)

 

添加,移除,替換,插入appendChild()removeChild()replaceChild()insertBefore() //在已有的子節點前插入一個新的子節點

 

查找getElementsByTagName()    //標籤名稱getElementsByName()    //經過元素的Name屬性的值getElementById()    //經過元素Id,惟一性

5題:

1. 使用Object.prototype.toString 去判斷!最好兼容性

if( Object.prototype.toString.call( someVar ) === '[object Array]' ) {

    alert( 'Array!' );

}

Array.isArray IE9如下不行

相關文章
相關標籤/搜索