欢迎来到天天文库
浏览记录
ID:55632378
大小:15.50 KB
页数:3页
时间:2020-05-21
《web前端笔试题及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、JS面试题及答案(转载自风雨潇潇的博客)一、JS闭包。f=function(){returntrue;};g=function(){returnfalse;};(function(){if(g()&&[]==![]){f=functionf(){returnfalse;};functiong(){returntrue;}}})();alert(f());//trueorfalse?------------------------答案:(function(){if(g()&&[]==![]){//应该看成if((g()&&[])==![])//因为g()是fa
2、lse后面那个&&[]就没起作用整个都是false//![]也是false所以if成立进入if块内f=functionf(){returnfalse;};//重新定义ffunctiong(){returntrue;}//这句没用}})();alert(f());//false二、截取字符串abcdefg的efgabcdefg
3、TML;varjiequ=myvalue.substring(myvalue.length-3,myvalue.length);alert(jiequ)三、写出一下运算结果alert(typeof(null))//objectalert(typeof(undefined))//undefinedalert(typeof(NaN))//numberalert(NaN==undefined)//falsealert(NaN==NaN)//falsevarstr="123abc";alert(typeof(str++))//numberalert
4、(str)//string四、写出函数DateDemo的返回结果,系统时间假定为今天functionDateDemo(){vard,s="今天日期是:";d=newDate();s+=d.getMonth()+"/";s+=d.getDate()+"/";s+=d.getYear();returns;}结果:今天日期是:7/17/2010五、写出程序运行的结果?for(i=0,j=0;i<10,j<6;i++,j++){k=i+j;}结果:10(小心陷阱)
此文档下载收益归作者所有