·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> 腾讯web前端笔试题及个人答案

腾讯web前端笔试题及个人答案

作者:佚名      ASP.NET网站开发编辑:admin      更新时间:2022-07-23

腾讯web前端笔试题及个人答案

每道题都有答案,大多数答案亲测正确。

简答题

1.js中“5”+4=?

答案:54

2.js中void(0)=?

答案:undefined

3.js中NaN*4=?

答案:NaN

4.js中null*4.5=?

答案:0

5.js中alert(5*015===5.075)

答案:false,结果不一样。

6.js中13>>2=? -13>>2=?

答案:3 ,-4 ,除以4,然后向下取整。

7.js中13|5=? 13&5=?

答案:按位或:13,按位与:5。

8.js中怎么获取当前日期的月份

答案:

[javascript]view plaincopyPRint?
  1. <spanstyle="font-size:18px;">vardate=newDate();varmouth=date.getMonth();</span>

9.js中数组排序方法是?该方法实现了什么的排序算法?

答案:排序方法是sort(),实现了按字符排序的算法。例var arr = [1,2,55,12,88];arr.sort();//ASCII字符代码从小到大排,arr结果为[1,12,2,55,88];

10.js中怎么判断Chrome浏览器?

答案:

[Javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;">isChrome=window.navigator.userAgent.indexOf("Chrome")!==-1;//
  2. 当isChrome=true时,为chrome浏览器</span>

11.js中var b=”hello”;a=b; 怎么显示出a的值(貌似这题最简单了)

答案:

[javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;">document.write(a);</span>

12.根据以下xml请写出对应的json

[plain]view plaincopyprint?
  1. <spanstyle="font-size:18px;"><xml>
  2. <list>
  3. <item>
  4. <id>12</id><name>张三</name>
  5. </item>
  6. <item><id>13</id><name>李四</name>
  7. </item>
  8. </list>
  9. </xml></span>

答案:

[javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;">varlists=[{"id":"12","name":"张三"},{"id":"13","name":"李四"}];</span>

13.js中怎么把十进制数123转化成二进制数?

答案:

[javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;">123.toString(2);</span>

14.js中怎么才能按下回车键可以提交

[javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;"><scripttype=”text/javascript”>
  2. document.onkeydown=function(event){
  3. event=event?event:window.event;
  4. if(event.keyCode==13){
  5. alert(“helloworld!”);
  6. }
  7. };
  8. </script></span>

编程题

1.js中var s=”tencent is sb”,编写js使其变成tencent1 is2 sb3

[javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;"><scripttype="text/javascript">
  2. vars="tencentisperfect";
  3. vararray=s.split("");
  4. s="";
  5. for(vari=0;i<array.length;i++){
  6. s+=array[i]+(i+1)+"";
  7. }
  8. document.write(s);
  9. </script></span>

2.编写js的类,使其拥有public和private类型的属性和方法

[javascript]view plaincopyprint?
  1. <spanstyle="font-size:18px;"><scripttype="text/javascript">
  2. functionPerson(_name,_age,_sex,_salary){
  3. //public
  4. this.name=_name;
  5. this.age=_age;
  6. //privare
  7. varsex=_sex;
  8. varsalary=_salary;
  9. //publicmethod
  10. this.getName=function(){
  11. returnthis.name;
  12. }
  13. this.getAge=function(){
  14. returnthis.age;
  15. }
  16. //privatemethd
  17. functiongetSex(){
  18. returnsex;
  19. }
  20. functiongetSalary(){
  21. returnsalary;
  22. }
  23. this.display=function(){
  24. document.write(this.getName()+"---"+this.getAge()+"---"+getSex()+"----"+getSalary());
  25. }
  26. }
  27. varsmirk=newPerson("zy","21","f","5000");
  28. smirk.display();
  29. </script></span>

3.说出一些常用的网络优化工具

答:优化大师,超级兔子SEO(Search Engine Optimization)缩写而来, 中文意译为“搜索引擎优化”。SEO优化工具:1.TrafficTravis——SEO分析工具2.Backlinkwatch.com—反链检测3.XENU Link Sleuth—死链检测4.SEO Tool Bar (火狐插件)5.SEO Quake (火狐插件)

面试官问的题

1.CSS的样式在不同类型的浏览器之间的显示差异如何解决答:(个人理解)先判断为何种浏览器,再为不同浏览器加载不同的cssa. CSS中几种浏览器对不同关键字的支持,可进行浏览器兼容性重复定义 !important 可被Firefox和IE7识别 * 可被IE6、IE7识别 _ 可被IE6识别 *+ 可被IE7识别b. 应用条件注释(只对IE有效),因为IE各版本的浏览器对我们制作的WEB标准的页面解释不一样,具体就是对CSS的解释不同,我们为了兼容这些,可运用条件注释来各自定义,最终达到兼容的目的。比如:

[html]view plaincopyprint?
  1. <spanstyle="font-size:18px;"><!–默认先调用css.css样式表–>
  2. <linkrel="stylesheet"type="text/css"href="css.css"/>
  3. <!–[ifIE7]>
  4. <!–如果IE浏览器版是7,调用ie7.css样式表–>
  5. <linkrel="stylesheet"type="text/css"href="ie7.css"/>
  6. <![endif]–>
  7. <!–[iflteIE6]>
  8. <!–如果IE浏览器版本小于等于6,调用ie.css样式表–>
  9. <linkrel="stylesheet"type="text/css"href="ie.css"/>
  10. <![endif]–></span>

2.在css中用一行css代码实现在不同类型的浏览器(如IE6,IE7,IE8)之间显示出不同的样式

[css]view plaincopyprint?
  1. <spanstyle="font-size:18px;">.mycolor{
  2. color:#FFF\9;/*IE6、7、8*/
  3. *color:#FF0;/*IE7、6*/
  4. _color:#F00;/*IE6*/
  5. }</span>

3.页面上有左中右三列,左右两列列宽固定,中间列自适应,要求纸上手写代码

[html]view plaincopyprint?
    1. <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2. <htmlxmlns="http://www.w3.org/1999/xhtml">
    3. <head>
    4. <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
    5. <title>三栏布局-浮动方法</title>
    6. <styletype="text/css">
    7. body,div,p{
    8. margin:0;
    9. padding:0;
    10. }
    11. #wrap{
    12. padding:0300px0200px;
    13. *overflow:hidden;
    14. }
    15. #main{
    16. float:left;width:100%;
    17. height:600px;
    18. background:#fffaba;
    19. }
    20. #left,#right{
    21. position:relative;
    22. height:600px;
    23. _display:inline;
    24. }
    25. #left{
    26. width:200px;
    27. float:left;
    28. margin-left:-100%;
    29. right:200px;
    30. _right:-300px;
    31. background:#8fc41f;
    32. }
    33. #right{
    34. width:300px;
    35. float:right;
    36. margin-right:-300px;
    37. background:#00b7ef;
    38. }
    39. </style>
    40. </head>
    41. <body>
    42. <spanstyle="white-space:pre"></span><divid="wrap">
    43. <divid="main">
    44. main
    45. </div>
    46. <divid="left">
    47. left
    48. </div>
    49. <divid="right">
    50. right
    51. </div>
    52. </div>
    53. </b