1.是否存在使i+1<i 的数,如果存在请说明情况?
答:存在,java中 int类型是32位 ,即 -2^32 -- 2^32-1 ,所以当i为2^32-1时,在+1会溢出,得到负数。
同理,存在 i-1>i 的情况。
2.输出结果
async function async1() {
console.log( 'async1 start' )
await async2()
console.log( 'async1 end' )
}
async function async2() {
console.log( 'async2' )
}
console.log( 'script start' )
setTimeout( function () {
console.log( 'setTimeout' )
}, 0 )
async1();
new Promise( function ( resolve ) {
console.log( 'promise1' )
resolve();
} ).then( function () {
console.log( 'promise2' )
} )
console.log( 'script end' )
答:
script start
async1 start
async2
promise1
script end
promise2
async1 end
setTimeout
3.输出结果
var a = '1-1'
var b = {
a : '1-2',
alert:function (){
console.log(a)
}
}
var c ={
a:'1-3'
}
b.alert()
c.alert = b.alert
c.alert()
答案:
1-1
1-1