js部分
1 //请写出输出内容 2 async function async1() { 3 console.log(‘async1 start‘); 4 await async2(); 5 console.log(‘async1 end‘); 6 } 7 async function async2() { 8 console.log(‘async2‘); 9 } 10 11 console.log(‘script start‘); 12 13 setTimeout(function() { 14 console.log(‘setTimeout‘); 15 }, 0) 16 17 async1(); 18 19 new Promise(function(resolve) { 20 console.log(‘promise1‘); 21 resolve(); 22 }).then(function() { 23 console.log(‘promise2‘); 24 }); 25 console.log(‘script end‘);
1 function fun(n,o) { 2 console.log(o) 3 return { 4 fun:function(m){ 5 return fun(m,n); 6 } 7 }; 8 } 9 var a = fun(0); 10 a.fun(1); a.fun(2); 11 a.fun(3); 12 var b = fun(0).fun(1).fun(2).fun(3); 13 var c = fun(0).fun(1); 14 c.fun(2); c.fun(3); 15 //问:三行a,b,c的输出分别是什么?
1 var length = 10; 2 function fn() { 3 console.log(this.length); 4 } 5 6 const obj = { 7 length: 5, 8 method: function(fn) { 9 fn(); 10 arguments[0](); 11 } 12 }; 13 14 obj.method(fn, 1);
Reference:
原文:https://www.cnblogs.com/JumperMan/p/12110875.html