深圳字节跳动笔试
今天去了深圳字节跳动笔试,记录一下,有时间研究透了再把答案贴上来
一、css实现滑块滑动
条件:
1.hover触发滑块滑动效果,要求滑块和背景都有过渡(transition)
2.只使用一个dom元素(伪元素)
3.滑块高度固定,宽度为未知父级的百分比,但是宽度始终大于高度
二、写出下面代码的执行结果
var total = 0; var result =[]; function foo(a){ for(var i = 0;i<3;i++){ result[i] =function(){ total += i*a; console.log(total) } } } foo(1) result[0](); result[1](); result[2]();
三、EvenLoop
async function async1() { console.log('async1 start'); await async2(); console.log('async1 end'); } async function async2() { console.log('async2 start'); return new Promise((resolve,reject)=>{ resolve(); console.log("async promise") }) } console.log('script start'); setTimeout(function () { console.log('setTimeout'); }, 0) async1(); new Promise(function (resolve) { console.log('promise1'); resolve(); }).then(function () { console.log('promise2'); }).then(function () { console.log('promise3'); }); console.log('script end');
四、写一个函数,实现二进制加法,例如
funcation binaryAdd(str1,str2){}
binaryAdd(“1010”,”111”)//10001
五、实现函数a,调用函数奇数次输出1,偶数次输出2(不能使用全局变量)
六、写出你认为最好得组合继承方式
附加题:
7给定一个长度为n得数组,给定一个数字k,求出数组中出现次数大于或等于n/k的数字
还有一个题都没看,一共就做了四十分钟,没来的及做完。看了网上其他童鞋在字节的面经,我的题目难度只能算是偏下,但是还是感觉自己答得不是很好,还是太菜了,面试官给我解答的时候真的是太懊悔了,自己应该太能写出来的。。。继续加油,向大佬们学习。
原文地址:https://segmentfault.com/a/1190000021176083