1. 程式人生 > >中科大軟院校招前端筆試題(記憶版)

中科大軟院校招前端筆試題(記憶版)

好玩的三道題:

筆試題:function foo(){ var i =0; return function(){ console.log(i++); } } var foo1 = foo(); var foo2 = foo(); foo1(); foo1(); foo2();//0 0 1

解析:第一次呼叫foo1()後,下次不再執行var i= 0了,直接呼叫return裡的函式

html佈局:佈局題:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><style> #father{ width: 300px; border: 1px solid red; } #child1{ width: 100px; height: 100px; background: red; float: left; } #child2{ width: 100px; height: 100px; background: blue; float: left; } #next{ width: 300px; height: 300px; background: yellow; }</style><body> <div id="father"> <div id = "child1">div1</div> <div id="child2">div2</div> </div> <div id = "next">hello</div></body><script></script></html>

注意下hello的位置,思考下為啥?注意最上方的那條紅線為啥?

考慮下position 的脫離文件流和float有什麼區別?

面試題三、function f(n){ n=n||2; return function(x){ return (x*n); }}var f2 = f(3);var f3 = f();console.log(f2(3));console.log(f3(3));console.log(f3(f2(3)));類似題一,上機試試?