答案:
js有哪幾種數據類型:
object(複雜類型)
number function boolean undefined string symbol(ES6)(基本類型)
其中typeof isNaN //Functionhtml
答案:
面向對象和麪向過程是兩種不一樣的編程思想。vue
答案:
1) 箭頭函數是匿名函數,不能做爲構造函數,不能使用new
2) 箭頭函數不綁定arguments,取而代之用rest參數...解決
3) 箭頭函數不綁定this,會捕獲其所在的上下文的this值,做爲本身的this值
4) 箭頭函數經過call()
或apply()
方法調用一個函數時,只傳入了一個參數,對 this 並無影響。
5) 箭頭函數沒有原型屬性
6) 箭頭函數不能當作Generator函數,不能使用yield關鍵字html5
答案:
eval() 函數計算 JavaScript 字符串,並把它做爲腳本代碼來執行es6
以防止一個函數被無心義的高頻率調用
防抖: 觸發事件後在 n 秒內函數只能執行一次,若是在 n 秒內又觸發了事件,則會從新計算函數執行時間。編程
節流: 指連續觸發事件可是在 n 秒中只執行一次函數
https://www.jianshu.com/p/c8b86b09daf0json
HTML5 如今已經不是 SGML(標準通用標記語言,是一種定義電子文檔結構和描述其內容的國際標準語言) 的子集,主要是關於圖像,位置,存儲,多任務等功能的增長。api
新標籤:
文檔類型設定:<!doctype html>
字符設定:
數組
增強語義化:瀏覽器
浮動引發的問題:
1)子元素浮動致使父元素內高度爲0,父級盒子不能被撐開,發生高度塌陷,父元素背景不能正常顯示,邊框不能被撐開,margin和padding值不能正常顯示。
2)與子元素同級的非浮動元素會被遮蓋
如何清除浮動?
1)給父元素設置合適的高度
2)給父元素添加樣式:overflow:hidden/auto
,這個屬性至關於觸發了BFC,讓父級緊貼內容
3)在最後一個子元素的後面追加一個空元素,併爲其添加樣式.clear{clear:both};
4)採用爲元素,給父元素後面追加:after
,並設置樣式爲.clearfix{content:""; clear:both; display:block;}
緩存
localStorage在全部同源窗口中都是共享的
<html manifest = "demo.appcache">...</html>
text/cache-manifest
。Application Cache的三個優點:
① 離線瀏覽
② 提高頁面載入速度
③ 下降服務器壓力
http://www.javashuo.com/article/p-hmzkrrnw-dp.html
var link = function(height = 50, color = 'red', url = 'http://azat.co') { ... }
//ES5 var name = 'Your name is ' + name + '.' var url = 'http://localhost:3000/api/messages/' + id //ES6 var name = `Your name is ${first} ${last}` var url = `http://localhost:3000/api/messages/${id}`
for(var i = 0; i < 10; i++){ setTimeout(function(){ console.log(i) },10) }
輸出:10個10
//改進: for(var i = 1; i <= 10; i++){ (function(i){ setTimeout(function(){ console.log(i) },10) })(i); } //改進2: for(let i = 0; i <= 10; i++){ setTimeout(function(){ console.log(i) },10) }
white-space:nowrap;/*強制在一行顯示*/ overflow:hidden;/*超出部分隱藏*/ text-overflow:ellipsis;/*文本超出部分用省略號代替*/
<style> *{ margin: 0; padding: 0; } .left{ width: 200px; float: left; height: 400px; background-color: #99F; } .main{ height: 400px; background: #ccc; } </style> <body> <div class="left">左側</div> <div class="main">主要</div> </body>
<style> *{ margin: 0; padding: 0; } .left{ width: 200px; position: absolute; top: 0; left: 0; height: 400px; background-color: #99F; } .main{ margin-left: 200px; height: 400px; background: #ccc; } </style> <body> <div class="left">左側</div> <div class="main">主要</div> </body>
<style> *{ margin: 0; padding: 0; } body{ display: flex; } .left{ width: 200px; height: 400px; background-color: #99F; } .main{ height: 400px; background: #ccc; flex: 1; } </style> <body> <div class="left">左側</div> <div class="main">主要</div> </body>
<style> *{ margin: 0; padding: 0; } .left{ width: 200px; height: 400px; float: left; background-color: #99F; } .main{ height: 400px; background: #ccc; } .right{ width: 200px; height: 400px; float: right; background-color: #99F; } </style> <body> <div class="left">左側</div> <div class="right">右側</div> <div class="main">主要</div> </body>
<style> *{ margin: 0; padding: 0; } .left,.right{ width: 200px; height: 400px; background-color: #99F; position: absolute; top: 0; } .left{ left:0; } .main{ height: 400px; background: #ccc; margin: 0 200px; } .right{ right: 0; } </style> <body> <div class="left">左側</div> <div class="right">右側</div> <div class="main">主要</div> </body>
<style> *{ margin: 0; padding: 0; } body{ display: flex; } .left,.right{ width: 200px; height: 400px; background-color: #99F; } .main{ height: 400px; background: #ccc; flex: 1; } </style> <body> <div class="left">左側</div> <div class="main">主要</div> <div class="right">右側</div> </body>