每道题都有答案,大多数答案亲测正确。
简答题
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中怎么获取当前日期的月份
答案:
<span style="font-size:18px;">var date = new Date(); var mouth = 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浏览器?
答案:
<span style="font-size:18px;">isChrome = window.navigator.userAgent.indexOf("Chrome") !== -1;//
当isChrome=true时,为chrome浏览器</span>
11.js中var b=”hello”;a=b; 怎么显示出a的值(貌似这题最简单了)
答案:
<span style="font-size:18px;">document.write(a);</span>
12.根据以下xml请写出对应的json
<span style="font-size:18px;"><xml>
<list>
<item>
<id>12</id><name>张三</name>
</item>
<item><id>13</id><name>李四</name>
</item>
</list>
</xml></span>
<span style="font-size:18px;">var lists = [{"id":"12","name":"张三"},{"id":"13","name":"李四"}];</span>
13.js中怎么把十进制数123转化成二进制数?
答案:
<span style="font-size:18px;">123.toString(2);</span>
14.js中怎么才能按下回车键可以提交
<span style="font-size:18px;"><script type=”text/javascript”>
document.onkeydown = function(event){
event = event?event:window.event;
if (event.keyCode == 13) {
alert(“hello world!”);
}
};
</script></span>
编程题
1.js中var s=”tencent is sb”,编写js使其变成tencent1 is2 sb3
<span style="font-size:18px;"><script type="text/javascript">
var s = "tencent is perfect";
var array = s.split(" ");
s = "";
for(var i=0; i < array.length; i ++){
s += array[i] + (i+1) + " ";
}
document.write(s);
</script></span>
2.编写js的类,使其拥有public和private类型的属性和方法
<span style="font-size:18px;"><script type="text/javascript">
function Person(_name,_age,_sex,_salary){
//public
this.name = _name;
this.age = _age;
//privare
var sex = _sex;
var salary = _salary;
//public method
this.getName = function(){
return this.name;
}
this.getAge = function(){
return this.age;
}
//private methd
function getSex(){
return sex;
}
function getSalary(){
return salary;
}
this.display = function(){
document.write(this.getName() + "---" + this.getAge() + "---" + getSex() + "----" + getSalary());
}
}
var smirk = new Person("zy","21","f","5000");
smirk.display();
</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的样式在不同类型的浏览器之间的显示差异如何解决
答:(个人理解)先判断为何种浏览器,再为不同浏览器加载不同的css
a. CSS中几种浏览器对不同关键字的支持,可进行浏览器兼容性重复定义 !important 可被FireFox和IE7识别 * 可被IE6、IE7识别 _ 可被IE6识别 *+ 可被IE7识别
b. 应用条件注释(只对IE有效),因为IE各版本的浏览器对我们制作的WEB标准的页面解释不一样,具体就是对CSS的解释不同,我们为了兼容这些,可运用条件注释来各自定义,最终达到兼容的目的。
比如:
<span style="font-size:18px;"><!– 默认先调用css.css样式表 –>
<link rel="stylesheet" type="text/css" href="css.css" />
<!–[if IE 7]>
<!– 如果IE浏览器版是7,调用ie7.css样式表 –>
<link rel="stylesheet" type="text/css" href="ie7.css" />
<![endif]–>
<!–[if lte IE 6]>
<!– 如果IE浏览器版本小于等于6,调用ie.css样式表 –>
<link rel="stylesheet" type="text/css" href="ie.css" />
<![endif]–></span>
2.在css中用一行css代码实现在不同类型的浏览器(如IE6,IE7,IE8)之间显示出不同的样式
<span style="font-size:18px;">.mycolor{
color:#FFF\9;/*IE6、7、8*/
*color:#FF0;/* IE7、6 */
_color:#F00;/* IE6 */
}</span>
3.页面上有左中右三列,左右两列列宽固定,中间列自适应,要求纸上手写代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>三栏布局-浮动方法</title>
<style type="text/css">
body,div,p{
margin:0;
padding:0;
}
#wrap {
padding:0 300px 0 200px;
*overflow:hidden;
}
#main {
float:left; width:100%;
height:600px;
background:#fffaba;
}
#left, #right {
position:relative;
height:600px;
_display:inline;
}
#left {
width:200px;
float:left;
margin-left:-100%;
right:200px;
_right:-300px;
background:#8fc41f;
}
#right {
width:300px;
float:right;
margin-right:-300px;
background:#00b7ef;
}
</style>
</head>
<body>
<span style="white-space:pre"> </span><div id="wrap">
<div id="main">
main
</div>
<div id="left">
left
</div>
<div id="right">
right
</div>
</div>
</body>
</html>