- 主页 > 生活百科 > >
- 下面关于Promise说法正确的是(注意“返回结果”的意思包含成功或者失败)
A. Promise.all在所有给定的promise都fulfilled后才返回结果B. Promise.race在给定的promise中,某个fulfilled后才返回结果C. promise.then的回调函数中,可以返回一个新的promiseD. 对于一个向后台获取数据已经产生结果的promise:p1,再次调用p1.then,不会去重新发起请求获取数据答案
ABC CDDOM
- 下列关于使用 JS 修改元素样式的代码,正确的有哪些?
document.body.style.['background-color'] = '#fff'document.body.style.setProperty('background-color', '#fff')document.body.style = 'background-color': #fff'document.body.style.fontSize = '14px' - 下列方法可用于阻止事件冒泡的有
A. event.cancelBubble = true;B. event.stopPropagation();C. event.preventDefault();D. return false;答案
BCD ABD填空题类型检测
- 在JavaScript中,有var arr = []; typeof arr的结果为
- 以下使用 typeof 操作符的代码的输出结果为
var x = typeof xvar res = typeof typeof x;console.log(x, res) - [typeof null, null instanceof Object]的结果是什么
- typeof typeof 0
- JavaScript的typeof运算符的可能结果为array?解释为什么
- 下面代码的输出结果是多少?
var arr = [];console.log(typeof arr, Object.prototype.toString.call(arr)); - console.log(Object.prototype.toString.call(undefined))
类型转换
- 表达式 "2"+3+4 的值为
- console.log('5' + 3, 5 + '3')
- var a=parseInt(“111办公室”);alert(a);
- ["0x1", "0x2", "0x3"].map(parseInt) 的结果
- 在js中执行 1+'1'的结果是?
- 在js中执行 parseInt('77',40)的结果是?
逻辑判断
- 请给出 [5<6<3,3<2<4] 代码的运行结果
- (2<3)||(3<2) 表达式将返回值为
- console.log(true||false&&false, true&&false||true)的输出结果是?
其他
- 1 + - + + + - + 1 的结果是
- [ 'a', ,'b', ,].length 的结果是
程序题JS基础
- 下面两个程序的输出结果分别是?
// case 1function showCase(value) {switch(value) {case 'A':console.log('Case A');break;case 'B':console.log('Case B');break;case undefined:console.log('Case undefined');break;default:console.log('Case default');}}showCase(new String('A'));// case 2function showCase(value) {switch(value) {case 'A':console.log('Case A');break;case 'B':console.log('Case B');break;case undefined:console.log('Case undefined');break;default:console.log('Case default');}}showCase(String('A')); - p标签的的内容会显示什么?
<html><body><p id="demo"></p><script type="text/javascript">var x = 10;var y = "10";document.getElementById("demo").innerHTML = Boolean(x == y);</script></body></html> - document.write的结果会是什么?
function funcA(x){var temp = 4;function funcB(y){document.write( ++x + y + (temp--));}funcB(5);}funcA(6) - alert的结果会是多少
var varArr = function(i,j,str) {return j == 0 ? str : varArr(i,--j,(str+= " " + i[j]));}var arr = new Array('apple','orange','peach','lime');var str = varArr(arr,arr.length,"");alert(str); - 下面程序的输出结果是多少?
function greetingMaker(greeting) {function addName(name) {greeting= greeting.split(' ').reverse().join("-");return greeting + " " + name;}return addName;}var daytimeGreeting = greetingMaker("Good Day to you");alert(daytimeGreeting(name)); - 下面程序的输出结果是多少?
String.prototype.GetNum = function() {var regEx = /[^d]/g;return this.replace(regEx, ''); };var str = "a1b2c3";str = str.GetNum();alert(str);
推荐阅读
-
-
-
烹饪|秋天常吃香菇身体好,但也要注意香菇一大禁忌,大家来了解一下吧
-
三吉彩花|还记得周杰伦MV女主三吉彩花?挑战“女同”电影,入围上影节
-
【真实】80年代农村真实老照片:每一张都是一段珍贵的童年记忆
-
-
小飞看娱乐|50岁张嘉译近照,头发苍白略显老态,走路需要搀扶
-
-
织女星|53年前被冷冻,等待2017年被复活的美国富豪,如今现状如何
-
隋唐|李元霸的双锤重800斤,换算成现代重量,有多少斤呢?
-
【文史记】每天闭门不出,结果被900公里外飘来的飞机砸死,他预言死于空难
-
-
-
-
【楠竹一】特朗普突然精神了,终于还是伸出了援手!一架俄飞机飞往大洋彼岸
-
上观新闻▲其中61例为境外输入病例,国家卫健委:8日新增确诊病例63例
-
-
湖人|冥冥之中!湖人24比8冲上热搜!梦幻开局+致敬科比
-
-
中国经济网|太突然!知名国际品牌宣布关店1200家!很多人都买过……