最新Web前端笔试题.doc
精品资料Web前端笔试题.1) 现在有以下 HTML 代码:<div class="wrapper"> <div class="box box1"></div> <div class="box box2"></div></div>补全下面的 CSSdiv.wrapper border: 1px solid #ccc; width: 200px; padding: 10px; / TODOdiv.box width: 50px; height: 50px; border: 1px solid #ccc;div.box1 / TODOdiv.box2 / TODO以达到以下效果:2) 补充完成下面的代码:function People (name) this.name = name;/ TODO/ ./ var jerry = new People('Jerry');jerry.sayHi(); / => 'Hi, I am Jerry'var lucy = new People('Lucy');lucy.sayHi(); / => 'Hi, I am Lucy'3) 补充下面的代码,尽量多地写出你能想到的实现方案。var arr = name: 'Jerry' , name: 'Lily' , name: 'Lucy' , name: 'Tomy' ;var arr2 = /* TODO */;arr = arr2; / => falsearr0 = arr20; / => truearr1 = arr21; / => truearr2 = arr22; / => truearr3 = arr23; / => true4) 补充 CSS 代码,让 p 元素内的文字 “垂直” 居中显示:HTML<p>Jerry is my love.</p>CSSp height: 30px; border: 1px solid #ccc; / TODO5) 写出标号处各打印的内容,并解释原因:<script type="text/javascript">var name = 'jerry'function sayHi () return 'Hi, I am ' + this.name;var lucy = name: 'Lucy', sayHi: sayHi, sayAnotherHi: function () return sayHi(); ;var tomy = name: 'Tomy'console.log(sayHi(); / 1:console.log(lucy.sayHi(); / 2:console.log(lucy.sayHi.apply(tomy); / 3:console.log(lucy.sayAnotherHi(); / 4:</script>6) HTTP是无状态协议,那么网站应该如何记住用户的登录状态?尽量详细回答整个过程。答:7) 写出标号处各打印的数值,并尽量解释原因:(function () var a = 0; function run() a = 1; function run2 () console.log(a); / 1: var a = 3; console.log(a); / 2: run2(); console.log(a); / 3: function run3 (a) console.log(a); / 4: a = 5; run3(8); console.log(a); / 5: function run4 () a = 4; console.log(a); /6: return run4; var result = run(); console.log(a); / 7: result(); console.log(a); / 8:)();8)页面上有以下元素:<ul id="list"> <li>This is Jerry</li> <li>This is Lucy</li> <li>This is Lily</li> <li>This is Tomy</li></ul>编写 JavaScript,使得点击页面的特定 li 元素就会 alert "元素的序号. 内容"。例如点击第一个元素,就会 alert 出 "1. This is Jerry"。(不能用jQuery,注意需要alert序号)/ TODO/ .9) 尽量多地列出你所知道的关于前端的技术(方法、框架等),并且简述其作用。答:10) 如果现在页面上出现了卡顿现象,例如鼠标移动不流畅,页面滚动不流畅,你会如何进行debug?答:11)编写 JavaScript 代码,让题目 1 的两个正方形可以在长方形内自由拖拽(可以使用 jQuery)。/ TODO.12) 编写一个 Children 类,继承题目 2 中的 People 类。/ TODOvar baby = new Children('Lucy', 12);baby.tellAge(); / => 'I am 12 years old'baby.sayHi(); / => 'Hi, I am Lucy'(baby instanceof People) / => true;13) 找出下面代码的规律并且编写一个函数,转换特定的整数到对应的字符串。1 => A2 => B3 => C.26 => Z27 => AA28 => AB29 => AC.52 => AZ53 => BA.function convert (num) / TODO