進程和線程的區別css
!important > 行內樣式>ID選擇器 > 類選擇器 > 標籤 > 通配符 > 繼承 > 瀏覽器默認屬性html
後面覆蓋前面的html5
閉包的做用:面試
使用場景瀏覽器
function func(param) { return function() { alert(param); } } var f = func(1) setTimeout(f, 1000);
function debounce(func, delay) { let timer; //該函數是一個閉包,因此timer會一直存在於內存中,而且timer只能在函數內部訪問 return function (...args) { if (timer) { clearTimeout(timer); } timer = window.setTimeout(() => { func.apply(this, args); }, delay); } }
垂直居中
用彈性盒子實現水平垂直居中閉包
<div class="parent"> <div class="children">我是經過flex的水平垂直居中噢!</div> </div> html,body{ width: 100%; height: 200px; } .parent { display:flex; align-items: center;/*垂直居中*/ justify-content: center;/*水平居中*/ width:100%; height:100%; background-color:red; } .children { background-color:blue; }
兩個做用app
alert(1 && 2) //2 括號裏面先計算,var a = 1 && 2; alert(a) alert(1 || 2) //1 括號裏面先計算,var a = 1 || 2; alert(a)
display:none //隱藏元素,不佔據文檔流 visibility:hidden //隱藏元素,不佔據文檔流
function C1(name) { if (name) this.name = name; }; C1.prototype.name = 'weilei'; console.log(new C1().name); // weilei function C2(name) { this.name = name; }; C2.prototype.name = 'weilei'; console.log(new C2().name); // undefined function C3(name) { this.name = name || 'sam'; }; C3.prototype.name = 'weilei'; console.log(new C3().name); // sam
惟一的區別是 onmouseenter 事件不支持冒泡socket
document.title = 'xxx'