这些javascript面试题,你做对了几道?

1.----------------------------------------------------

var fun = function(){
this.name = 'peter';

return {
name: 'jack'
};

}

var p = new fun();

 

请问p.name是:

a:'peter', b:'jack', c:null, d:undefined

2.----------------------------------------------------

var fun = function(){
this.name = 'peter';

return 'jack';    
}

var p = new fun();

 

请问p.name是:

a:'peter', b:'jack', c:null, d:undefined

3.----------------------------------------------------

var fun = function(){

}

fun.prototype = {
info : {
name : 'peter',
age : 25
}
}

var a = new fun();
var b = new fun();

a.info.name = 'jack';
b.info.name = 'tom';

 

请问a.info.name和b.info.name分别是:

a:'jack', 'tom', b:'jack', 'jack', c:'tom','tom', d:'tom', 'jack'

4.----------------------------------------------------

var fun = function(){
this.info = {
name : 'peter',
age : 25
}
}

var a = new fun();
var b = new fun();

a.info.name = 'jack';
b.info.name = 'tom';

 

请问a.info.name和b.info.name分别是:

a:'jack', 'tom', b:'jack', 'jack', c:'tom','tom', d:'tom', 'jack', e:其它

5.----------------------------------------------------

var fun = function(){

}

fun.prototype = {    
name : 'peter',    
age : 25    
}

var a = new fun();
var b = new fun();

a.name = 'jack';
b.name = 'tom';

 

请问a.name和b.name分别是:

a:'jack', 'tom', b:'jack', 'jack', c:'tom','tom', d:'tom', 'jack', e:其它

6.----------------------------------------------------

var fun = function(){
this.info = {
name : 'peter',
age : 25
}
}

fun.prototype = {
info : {
name : 'peter',
age : 25
}
}

var a = new fun();
var b = new fun();

a.info.name = 'jack';
b.info.name = 'tom';

 

请问a.info.name和b.info.name分别是:

a:'jack', 'tom', b:'jack', 'jack', c:'tom','tom', d:'tom', 'jack'

posted @ 2014-11-09 23:44  rezy  阅读(3419)  评论(9编辑  收藏  举报