校招拼多多笔试题(前端工程师)
2017-09-02 16:29
991 查看
0)
考试时间:2017-09-02-提前批内推-笔试
为了笔试结束后总结,我考试时截了图,然后选取几道有质量的题目。总的来说,坑还是很多的。
测试代码:所在仓库
1)
测试代码如下:
a[b]通过索引’[object Object]’获取到对象a的一个属性。之所以结果是456,是因为
选D
2)
测试代码
var a = b = 3 这段代码是从右往左执行的。先执行b =3 , 由于b在函数内未声明,所以被认为是全局变量,所以可以外部被访问,变量a在函数内被声明,所以在外部访问不到。
选A
3)
关于NaN:
NaN compares unequal (via ==, !=, ===, and !==) to any other value – including to another NaN value.
选C
4)
测试结果
选C
5)
var关键字的作用是声明提升。如果只是赋值
选A
6)
看文档
new Date();
new Date(value);
new Date(dateString);
new Date(year, month[, date[, hours[, minutes[, seconds[, milliseconds]]]]]);
Parameters
value
Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored (Unix Epoch; but consider that most Unix time stamp functions count in seconds).
dateString
String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601).
year
Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999. See the example below.
month
Integer value representing the month, beginning with 0 for January to 11 for December.
date
Optional. Integer value representing the day of the month.
hours
Optional. Integer value representing the hour of the day.
minutes
Optional. Integer value representing the minute segment of a time.
seconds
Optional. Integer value representing the second segment of a time.
milliseconds
Optional. Integer value representing the millisecond segment of a time.
new Date(dateString);这种方式实则调用Date.parse(),所以是这样的:
而Date.parse()这个函数在不同浏览器上的行为是不一样的,所以不符合题意。
选A
7)
各种黑科技啊
选D
8)
只有在同一个元素上相继触发mousedown和mouseup事件,才会触发click事件,所以
选D
9)
直接看结果:
答案是都可以的,为什么呢。
setInterval和setTimeout一样,不能保证程序从什么时候开始执行。它内部的代码会进入一个消息队列,要等到执行栈空闲,且该代码在消息队列队首才会执行,所有是有延迟的。
其中涉及JS异步编程的原理。详见:JavaScript异步编程的原理
选D
10)
测试结果:
选B
另:如何使得一个不显示,详见 Five Ways to Hide Elements in CSS
11)
关于盒子模型,详见: 盒子模型和box-sizing属性
选D
12)
基本包装类型比较的是对象的地址。
13)
请读者自行查阅文档,还是很简单的。
选B
14)
这个可以查阅文档:推荐书籍《图解HTTP》
选ABCD
15
一切引起改变元素位置和几何的属性变化都会引起回流
详见 :网页性能管理详解
选ABCD
16)
考察排序算法稳定性,很简单。
选A,D
17)
我对HTTP2.0不是很了解,详见:拼多多考试总结
另外:在HTTP/1,gzip用来压缩请求体,HTTP2.0用了新技术压缩请求头,但不是gzip,详见HTTP/2 头部压缩技术介绍
选BCD
18)
选ACD
《JS高级程序设计》第2版P145提到了new关键字,new使用时会创建一个新对象,并将构造函数作用域赋给了新对象(因此this指向了新对象)
详见:
事件处理中的this:attachEvent, addEventListener, onclick
【重难点】js中this关键字的指向
19)
闭包实现
20)
一道算法题
暴力复杂度有O(N^3)这样肯定是不行的。
网上找到一种效率更高的,见 此文, 搜O(n2)定位
考试时间:2017-09-02-提前批内推-笔试
为了笔试结束后总结,我考试时截了图,然后选取几道有质量的题目。总的来说,坑还是很多的。
测试代码:所在仓库
1)
测试代码如下:
var a = {}; b = { key: 'b' }; c = { key: 'c' }; a[b] = 123; a[c] = 456; console.log(a); //{ '[object Object]': 456 } console.log(a[b]); //456
a[b]通过索引’[object Object]’获取到对象a的一个属性。之所以结果是456,是因为
a[b]和
a[c]获取到的是同一个属性,
a[c]=456这行代码覆盖了原有属性。
选D
2)
测试代码
(function() { var a = b = 3; })(); console.log(typeof a !== 'undefined'); // false console.log(typeof b !== 'undefined'); // true
var a = b = 3 这段代码是从右往左执行的。先执行b =3 , 由于b在函数内未声明,所以被认为是全局变量,所以可以外部被访问,变量a在函数内被声明,所以在外部访问不到。
选A
3)
console.log(NaN == NaN); //false console.log(NaN === NaN); //false console.log(undefined == null); //true console.log(undefined === null); //false
关于NaN:
NaN compares unequal (via ==, !=, ===, and !==) to any other value – including to another NaN value.
选C
4)
<!DOCTYPE> <html> <head> <style> </style> </head> <body> <input id="target" type="text"> <script> var input = document.getElementById('#target'); target.onmousedown = function() { console.log('onmousedown'); } target.onmouseup = function() { console.log('onmouseup'); } target.onclick = function() { console.log('onclick'); } target.onfocus = function() { console.log('onfucs'); } </script> </body> </html>
测试结果
onmousedown onfucs onmouseup onclick
选C
5)
var a1 = 111; console.log(a1); //111 console.log(a2); // undefined console.log(a3); // a3 in not defined var a2 = 222; a3 = 333;
var关键字的作用是声明提升。如果只是赋值
a3=333并不能提升声明。而且提升的只是声明部分,不包括赋值。
选A
6)
看文档
new Date();
new Date(value);
new Date(dateString);
new Date(year, month[, date[, hours[, minutes[, seconds[, milliseconds]]]]]);
Parameters
value
Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC, with leap seconds ignored (Unix Epoch; but consider that most Unix time stamp functions count in seconds).
dateString
String value representing a date. The string should be in a format recognized by the Date.parse() method (IETF-compliant RFC 2822 timestamps and also a version of ISO8601).
year
Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999. See the example below.
month
Integer value representing the month, beginning with 0 for January to 11 for December.
date
Optional. Integer value representing the day of the month.
hours
Optional. Integer value representing the hour of the day.
minutes
Optional. Integer value representing the minute segment of a time.
seconds
Optional. Integer value representing the second segment of a time.
milliseconds
Optional. Integer value representing the millisecond segment of a time.
new Date(dateString);这种方式实则调用Date.parse(),所以是这样的:
new Date(Date.parse(dataString))
而Date.parse()这个函数在不同浏览器上的行为是不一样的,所以不符合题意。
选A
7)
各种黑科技啊
console.log(1 + '2' + '2'); //122 console.log(1 + +'2' + '2'); //32 // + 是一元操作符 +'2' 实则调用Number('2'); console.log(1 + -'1' + '2'); // // - 也是一元操作符,和+一元操作符相比,除了正负不同,其他同理 console.log(+'1' + '1' + '2'); //112 console.log('A' - 'B' + '2'); // NaN2 // 'A'-'B' 调用toString(), NaN-NaN -> NaN,然后字符串拼接 console.log('A' - 'B' + 2); //NaN + 2 -> NaN
选D
8)
只有在同一个元素上相继触发mousedown和mouseup事件,才会触发click事件,所以
选D
9)
直接看结果:
答案是都可以的,为什么呢。
setInterval和setTimeout一样,不能保证程序从什么时候开始执行。它内部的代码会进入一个消息队列,要等到执行栈空闲,且该代码在消息队列队首才会执行,所有是有延迟的。
其中涉及JS异步编程的原理。详见:JavaScript异步编程的原理
选D
10)
<!DOCTYPE> <html> <head> <style> .one { z-index: 0; } .two { opacity: 0; } .three { width: 0; height: 0; } </style> </head> <body> <div class="one">hello world one z-index</div> <div class="two">hello world two opacity</div> <div class="three">hello world three height = width = 0</div> <script> </script> </body> </html>
测试结果:
选B
另:如何使得一个不显示,详见 Five Ways to Hide Elements in CSS
11)
关于盒子模型,详见: 盒子模型和box-sizing属性
选D
12)
基本包装类型比较的是对象的地址。
var s1 = new String('zxc'); var s2 = new String('zxc'); console.log(s1 == s2);//false console.log(s1 === s2);//false
13)
请读者自行查阅文档,还是很简单的。
选B
14)
这个可以查阅文档:推荐书籍《图解HTTP》
选ABCD
15
一切引起改变元素位置和几何的属性变化都会引起回流
详见 :网页性能管理详解
选ABCD
16)
考察排序算法稳定性,很简单。
选A,D
17)
我对HTTP2.0不是很了解,详见:拼多多考试总结
另外:在HTTP/1,gzip用来压缩请求体,HTTP2.0用了新技术压缩请求头,但不是gzip,详见HTTP/2 头部压缩技术介绍
选BCD
18)
选ACD
《JS高级程序设计》第2版P145提到了new关键字,new使用时会创建一个新对象,并将构造函数作用域赋给了新对象(因此this指向了新对象)
详见:
事件处理中的this:attachEvent, addEventListener, onclick
【重难点】js中this关键字的指向
19)
闭包实现
//实则是个闭包 function mul(num) { return function(num2) { return function(num3) { return num * num2 * num3; } } } console.log(mul(2)(3)(4));//24
20)
一道算法题
暴力复杂度有O(N^3)这样肯定是不行的。
网上找到一种效率更高的,见 此文, 搜O(n2)定位
相关文章推荐
- 挖财2017校招前端工程师笔试试卷
- 前端 2018 届校招笔试面经【百度,阿里,腾讯,阿里文娱,携程,美团,拼多多】
- 2017盛大游戏2017前端工程师校招笔试题总结
- 去哪儿网2017校招在线笔试(前端工程师)编程题及JavaScript代码
- [置顶] 美丽联合2018校招前端开发工程师笔试试卷及解析
- 盛大游戏2017校招前端工程师笔试试卷
- 同程2017校招前端工程师笔试试卷
- 简单易懂的秒杀服务(模拟题) - 拼多多2018提前批笔试-服务器端开发工程师
- 京东2017校招笔试编程题iOS开发工程师
- 2012 腾讯校招Web前端笔试的一道题,很值得怀念。。。
- 笔试题,百度流程信息管理部Web前端实习研发工程师
- 前端简单实现校招笔试'作弊监听'功能
- 2016阿里校招算法工程师笔试
- 2017 搜狗校招c++工程师笔试试卷
- 阿里巴巴 2014校招 研发工程师 笔试
- 阿里巴巴2016前端工程师笔试题1总结
- web前端开发工程师笔试题
- RGB转换实现代码,淘宝前端开发工程师笔试题
- 阿里巴巴校招2017前端笔试题目 -- 原生js/html5 实现一个路由
- 机器学习/数据挖掘工程师校招笔试题目总结。