进程和线程的区别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'