以下代码输出
console.log([1,2,3,4,5].splice(1,2,3,4,5));
console.log([1,2,3,4,5].slice(1,2,3,4,5));
// 输出:[2,3]和[2]
- slice-实现了从原数组中截取一部分,并返回所截取的数组对象。slice(start, end)。
- splice-从原数组删除或者插入一部分内容。splice(index, howmany, item1, …itemx )。index -从当前索引删除,howmany,代表删除个数,items…-要添加的元素。返回值为被删除的数组对象。
root元素的高 (通过getComputedStyle(root).height计算) 为?
<html>
<body>
<div id="root" style="border:1px solid red;">
<div style="width:10px;height:10px;margin:10px;"></div>
<div style="width:10px;height:10px;margin:20px;"></div>
</div>
</body>
</html>
// 输出:70px
- border形成BFC,两个子组件margin重叠,取大。
- 如果块元素的 margin-top 与它的第一个子元素的 margin-top 之间没有 border、padding等来分隔,或者块元素的 margin-bottom与它最后一个子元素的 margin-bottom 之间没有 border、padding、height、min-height、max-height 分隔,那么外边距会塌陷。子元素多余的外边距会被父元素的外边距截。
- 链接: https://www.jianshu.com/p/16c58ef8b7c8.