全是本人乱写
1.下面输出结果是多少?
(function(){
var x = y =1;
})
console.log(x)
console.log(y)
解答: 闭包问题,闭包内的变量不会带到外面
2.制作级联菜单的时候,调用的是下拉列表的哪个事件? 解答: onChange()
3.如何用js判断字符串中包含某一子串? 解答: 使用indexOf() 如果存在则返回位置,不存在则返回 -1
4.有表达式 [1<2<3,3<2<1] , 运行后结果是多少? 解答: [true,true]
image.png
因为首先3<2为false,然后false<1 即为 0<1,所以为true
5.一个没有经过任何css样式修饰的html文件,1rem等于多少px? 解答: 16px
6.以下三个表达式的值是多少?
3.toString
3..toString
3...toString
解答:
image.png
7.代码填空
//define
(function(window){
function fn(str){
this.str = str;
}
fn.prototype.format = function() {
var arg = ______;
return this.str.replace(_____,function(a,b){
return arg[b] || "";
})
}
window.fn = fn
})(window);
//use
(function(){
var t = new fn('<p><a href="{0}">{1}</a><span>{2}</span></p>');
console.log(t.format('http://www.duoyi.com','duoyi','Welcome'));
})();
8.简述触发BFC的方式 解答:参考:https://developer.mozilla.org/zh-CN/docs/Web/Guide/CSS/Block_formatting_context
float
不是 none
)position
为 absolute
或 fixed
)display
为 inline-block
)display
为 table-cell
,HTML表格单元格默认为该值)display
为 table-caption
,HTML表格标题默认为该值)display
为 table、``table-row
、 table-row-group、``table-header-group、``table-footer-group
(分别是HTML table、row、tbody、thead、tfoot的默认属性)或 inline-table
)overflow
值不为 visible
的块元素display
值为 [flow-root](https://drafts.csswg.org/css-display/#valdef-display-flow-root)
的元素contain
值为 layout
、content
或 strict
的元素display
为 flex
或 inline-flex
元素的直接子元素)display
为 grid
或 inline-grid
元素的直接子元素)column-count
或 column-width
不为 auto,包括 ``column-count
为 1
)column-span
为 all
的元素始终会创建一个新的BFC,即使该元素没有包裹在一个多列容器中(标准变更,Chrome bug)。