以下代码的执行结果是: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个
构造方法在( ),一般不能显式地直接调用
A. 创建对象时自动执行
B. 任意时候