1,
setTimeout(()=>{console.log(1)})let promise = new Promise(function(resolve,reject){ console.log('Promise'); resolve();});promise.then(function(){ console.log('resolved');});console.log('Hi!');// 输出分别是:Promise Hi! resolved 1 //(555)复制代码
2,
var obj = { name: 'xiaoming', get: function(){ fn() }}var name = 'globle'function fn(){ console.log(this.name)}obj.get()// globle复制代码
3,
a,b两个值的交换第一种方法:结构赋值,[a,b] = [b,a] // 对数组和对象的值的提取并赋值??第二种方法:a = { a: a, b:b}b= a.aa = a.b第三种:a = [b, b=a][0] // 运算先后// 无敌!!! 好吧,我是彩笔复制代码