前几天遇到的笔试题
来源:互联网 发布:linux链接oracle 编辑:程序博客网 时间:2024/04/30 16:36
1. 按顺序写出打印结果
(function(){ console.log("1_script start"); Promise.resolve().then(function(){ console.log("2_promise1"); }).then(function(){ console.log("3_promise2"); }); var avar; avar += [2018]; console.log("4_avar : "+avar); //"undefined2018" var aarray = [1,2,3]; aarray.length = 0; console.log("5_aarray[1] : "+aarray[1]); //undefined console.log("6_typeof foo : "+typeof foo); //'function' console.log("7_typeof bar : "+typeof bar); //'undefined' var foo = 'hello', bar = function(){ return "world"; }; function foo(){ return "hello" } var funcs = []; for (let i = 0; i < 4; i++) { funcs.push( () => i); } console.log("8_funcs[2]() : "+funcs[2]()); //2 (function(){ var i = 2018; console.log("9_funcs[2]() : "+funcs[2]()); //2 })(); setTimeout(function(){ console.log("10_setTimeout"); },0); console.log("11_script end") })();
运行结果:
"1_script start""4_avar" : "undefined2018""5_aarray[1]" : "undefined""6_typeof foo" : "function""7_typeof bar" : "undefined""8_funcs[2]()" : 2"9_funcs[2]()" : 2"11_script end""2_promise1""3_promise2""10_setTimeout"
2. 顶部底部固定高度,中间部分铺满屏幕剩余高度,中间盒子里又左盒子固定宽度,右盒子自适应宽度且距左盒子总是20px
html:
<body><div class="top">顶部,高度40px</div><div class="mainBox"> <div class="leftBox">左盒子,固定宽度200px,高度自适应铺满屏幕剩余高度</div> <div class="rightBox">右盒子,距离左盒子20px,高度自适应宽度自适应铺满屏幕剩余高度</div></div><div class="bottom">底部,高度40px</div></body>
css:
*{ margin:0; padding:0; } .top { width: 100%; height: 40px; background: #000; color:#fff; position:absolute; top:0; /*以上设置是重点必须的*/ text-align:center; line-height:40px; } .bottom{ width:100%; height:40px; background:#000; color:#fff; position:absolute; bottom:0; /*以上设置是重点必须的*/ text-align:center; line-height:40px; } .mainBox{ width:100%; position:absolute; top:40px; bottom:40px; /*以上设置是重点必须的*/ } .mainBox .leftBox{ height:100%; width:200px; float:left; margin-bottom:40px; overflow: auto; /*以上设置是重点必须的*/ border:6px solid green; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; text-align:center; line-height:40px; } .mainBox .rightBox{ height:100%; margin-left:220px; /*以上设置是重点必须的*/ border:6px solid crimson; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; overflow: auto; text-align:center; line-height:40px; }
- 判断一个对象是否属于某个类
//假设 var obj = new foo(); obj instanceof fooobj.contructor.name == "foo"obj.__proto__ == foo.prototype
4. new操作符具体干了写什么(真是服了这个题目)
function foo(){};var obj = new foo();
//1. 创建了一个空对象var obj = new Object();//2. 设置原型链obj.__proto__ = foo.prototype;//3. 让foo中的this指向obj,执行foo的函数体var res = foo.call(obj);//4. 判断foo的返回值类型if(typeof res == 'object'){ foo = res;}else{ foo = obj;}
5. display: inline-block什么时候会显示间隙
html:
<body><div class="box"> <div></div> <div></div> <div></div> <div></div> <div></div></div></body>
css:
<body><div class="box"> <div></div> <div></div> <div></div> <div></div> <div></div></div></body>
水平方向和垂直方向都有间隙
解决方法:
水平:
- 为box(父元素)添加 font-size: 0; - 子元素标签不换行(不推荐)
垂直:
- 为子元素添加:vertical-align:bottom;
- 在子元素中添加任意文字
6. 结果不会打印”timeout”
var timer = setTimeout(function(){ console.log("timeout"); }); clearTimeout(timer)
7. 运算
var a = 0,b = 2; //b++ , 在这一行中b的值是不变的 //++b,b的值为+1后的值 a = b+++5*++b,b的值为; console.log(a) //22
var a = 1, b = "2", c; c = a+b; console.log(c) //"12"
//数字转为响应的字母//大写String.fromCharCode(64 + parseInt(2)) //B//小写String.fromCharCode(96 + parseInt(1)); //a
阅读全文
0 0
- 前几天遇到的笔试题
- 前几天阿里巴巴的笔试题
- 前几天的遇到的一个错误,引以为戒
- 关于前几天金山网络笔试的一道题-2014年4月28号
- C++设计模式(前几天笔试碰到的。。。囧)
- 大家进来看看这个问题 前几天的一个笔试题目
- 前几天面试遇到一个中文编码的问题!
- 趁热打铁,写下前几天做TOLO3G项目遇到的小问题
- 前几天遇到的网页打不开解决方法
- 今天遇到的笔试题
- 笔试中遇到的题
- 遇到的一些笔试题
- 笔试遇到的编程题
- 遇到的前端笔试题
- 遇到的几个奇怪的笔试题
- Java 笔试中经常遇到的10道笔试题
- Java 笔试中经常遇到的笔试题
- Java 笔试中经常遇到的笔试题
- POJ 3784 对顶堆动态维护中位数 解题报告
- js中WINDOW对象中的navigator成员对象
- JSON.parse()和JSON.stringify()
- js中WINDOW对象中的location成员对象
- jquery selectPage插件的使用
- 前几天遇到的笔试题
- MySql查询某一天的数据
- Android自定义控件三部曲文章索引
- MyEclipse6.5下安装maven插件
- Zabbix漏洞及其利用姿势(附EXP)
- MYsql数据冗余
- jieba库的使用
- Eclipse配置git
- ZOJ-1610(区间染色)