前端基础培训随堂测试题6.docx
- 文档编号:30731564
- 上传时间:2023-08-19
- 格式:DOCX
- 页数:9
- 大小:41.52KB
前端基础培训随堂测试题6.docx
《前端基础培训随堂测试题6.docx》由会员分享,可在线阅读,更多相关《前端基础培训随堂测试题6.docx(9页珍藏版)》请在冰豆网上搜索。
前端基础培训随堂测试题6
一、基础知识填空
JS中的数据类型包含哪些(要求详细)以及基本数据类型和引用数据类型的本质区别:
__________________
JS中如何的检测数据类型(写出四种方法):
_____________________JS中判断某个值是否是一个有效数字的方法是:
_______________
想要接收函数执行的时候传递的参数,都可以如何的处理:
_______________将其他的数据类型转化为number类型的方式有那些:
________________
二、写出DOM中常用的方法和属性
有一个div:
__________
获取当前浏览器屏幕的宽度和高度(兼容所有的浏览器):
_______________获取上一个哥哥元素节点(兼容所有的浏览器):
________________
动态创建一个div标签,并且添加到body的最后面位置:
_______________继续上一题,把刚才创建的克隆一份一模一样的,添加到刚才创建的div前面:
______________
三、数组的基础知识和应用
我想删除数组中的最后一项,至少写出两种办法:
_____________________我想在数组的末尾增加一个元素,至少写出两种办法:
__________________
基于原来的数组复制一份一模一样新的数组,不考虑原有数组是否改变的情况,请写出至少三种方案:
_____________________
数组从小到大排序(可以处理10以上的数字):
______________________实现找到第n项到第m项的内容,返回一个新的数组(原有数组不变):
______________
四、写出下面表达式的运算结果
[]==false:
____________!
[]==false:
____________[]==!
[]:
______________Number(“13px”)==NaN:
___________5+”3”-2:
___________________
If(“3px”*3){alert(“true”)}else{alert(“false”)}:
____________If(“3px”+3){alert(“true”)}else{alert(“false”)}:
___________
If(document.body){alert(“ok”);}else{alert(“no”)}:
_______________alert([]):
______________null==undefined:
________________
5、
varary=[“red”,”yellow”,”pink”,”green”,”blue”];
以上是页面中的5个按钮,和一个存储五个颜色值的数组,要求实现一个方法bindEvent,循环给5个按钮绑定点击事件,当点击的时候,整个body的背景颜色正好可以和数组中的指定项颜色对应(例如:
点击第三个按钮,body的背景颜色”pink”),请按照你的思路来实现?
六、画图分析
varary=[1,2,3,4];
functionfn(ary){
ary[0]=0;ary=[0];ary[0]=100;returnary;
}
varres=fn(ary);console.log(ary);console.log(res);//此题偏难,认真思考(360面试题难度降低版本代码)
二、选择题:
(要求写出分析步骤/画图)
1、console.log(a);
vara=12;
functionfn(){
console.log(a);
vara=13;
}
fn();
console.log(a);
输出的三次分别是多少
A、undefined1213B、undefinedundefined12
C、undefinedundefined13D、有程序报错
2、console.log(a);
vara=12;
functionfn(){
console.log(a);
a=13;
}
fn();
console.log(a);
A、undefined1213B、undefinedundefined12
C、undefinedundefined13D、有程序报错
3、console.log(a);
a=12;
functionfn(){
console.log(a);
a=13;
}
fn();
console.log(a);输出的三次分别是多少
A、undefined1213B、undefinedundefined12
C、undefinedundefined13D、有程序报错
4、varfoo=1;
functionbar(){
if(!
foo){
varfoo=10;
}
console.log(foo);
}
bar();输出的结果是多少
A、1B、10C、undefinedD、报错
5、varn=0;
functiona(){
varn=10;
functionb(){
n++;
alert(n);
}
b();
returnb;
}
varc=a();
c();
alert(n);
弹出三次的结果分别是什么?
A、111B、11110C、11120D、111212
6、vara=10,b=11,c=12;
functiontest(a){
a=1;varb=2;c=3;
}
test(10);
alert(a);alert(b);alert(c);弹出的三个值分别是多少?
A、1113B、101112C、123D、10113
7、if(!
("a"inwindow)){
vara=1;
}
alert(a);
弹出的a的值是?
A、1B、undefinedC、报错D、以上答案都不对
8、vara=4;
functionb(x,y,a){
alert(a);
arguments[2]=10;
alert(a);
}
a=b(1,2,3);alert(a);三次弹出的结果是
A、334B、3104C、31010D、310undefined
9、varfoo='hello';
(function(foo){
console.log(foo);
varfoo=foo||'world';
console.log(foo);
})(foo);
console.log(foo);三次分别输出什么?
A、hellohellohelloB、undefinedworldhelloC、helloworldworldD、以上答案都不正确
10、vara=9;
functionfn(){
a=0;
returnfunction(b){returnb+a++;}
}
varf=fn()
varm=f(5);alert(m);
varn=fn()(5);alert(n);
varx=f(5);alert(x);
alert(a);弹出的四次结果?
A、6672B、5673C、5563D、以上答案都不正确
三、思考题:
1、document.parentNode的值是什么,为什么
2、document.parentnode的值是什么,为什么。
3、prototype是谁的属性,它起什么作用?
__proto__是谁的属性,它有什么作用?
prototype和__proto__有什么联系?
4、hasOwnProperty和in都是用来判断对象的属性的,这两个是怎么用的,有什么区别?
5、什么是闭包,它有什么作用?
4、附加题画图/分析步骤
1、
functionfn(i){
returnfunction(n){
console.log(n+(i++));
}
}
varf=fn(10);
f(20);
fn(20)(40);
fn(30)(50);
f(30);
2、
vari=10;
functionfn(){
returnfunction(n){
console.log(n+(++i));
}
}
varf=fn();
f(20);
fn()(20);
fn()(30);
f(30);
3、
varnum=10;
varobj={num:
20};
obj.fn=(function(num){
this.num=num*3;
num++;
returnfunction(n){
this.num+=n;
num++;
console.log(num);
}
})(obj.num);
varfn=obj.fn;
fn(5);
obj.fn(10);
console.log(num,obj.num);
4、
functionFn(){
this.x=100;
this.y=200;
this.getX=function(){
console.log(this.x);
}
}
Fn.prototype.getX=function(){
console.log(this.x);
};
Fn.prototype.getY=function(){
console.log(this.y);
};
varf1=newFn;
varf2=newFn;
console.log(f1.getX===f2.getX);
console.log(f1.getY===f2.getY);
console.log(f1.__proto__.getY===Fn.prototype.getY);
console.log(f1.__proto__.getX===f2.getX);
console.log(f1.getX===Fn.prototype.getX);
console.log(f1.constructor);
console.log(Fn.prototype.__proto__.constructor);
f1.getX();
f1.__proto__.getX();
f2.getY();
Fn.prototype.getY();
5、我想通过下面的代码实现选项卡,请问是否可以实现?
不能的话,说明原因,那么你有几种办法可以解决?
(面试必考题)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 前端 基础 培训 测试