题目内容

以下代码的执行结果是?n=10setTimeout(()=>{n++},0)let prom = new Promise((resolve,reject)=>{console.log('prom:',n)if(n>10)resolve()elsereject()})prom.then(val=>{console.log('then:',n)}).catch(err=>{console.log('catch:',n)})n++

A. prom: 10then: 10
B. prom: 10then: 11
C. prom: 10catch: 10
D. prom: 10catch: 11

查看答案
更多问题

以下代码的执行结果是:function inc(){return new Promise((resolve,reject)=>{if(n<2){n++resolve(n)}elsereject(n)})}async function print(){for (let i=0;i<5;i++){await inc()console.log("print:"+n)}}n=0print().catch(val=>{console.log("catch:"+val)})

A. print:1print:2catch:2
B. print:1print:2catch:3
C. print:1print:2catch:2catch:2catch:2
D. print:1print:2catch:3catch:4catch:5

当变量str为何值时,以下表达式结果为true/^(ab)\D+[^1-9]$/.test(str)

A. 'abc1'
B. 'abcd'
C. 'cabd'
D. 'abc0'
E. 'ab0c'

在ES6当中,Promise对象有以下几种状态

A. fullfilled
B. rejected
C. pending
D. end

在一个类中,可以定义()个构造方法

A. 只能定义1个
B. 无需定义
C. 可以定义多个
D. 只能定义一个或0个

答案查题题库