//箭头函数
// ()中定义参数,如果只有一个参数,可以不写括号
//{}中写函数体,如果函数体中只有返回值,可以不写return
//区别:普通函数,谁调用这个函数,this指向谁,箭头函数,在哪里定义函数,this指向谁
const fun = () => {
return 100;
}
const fun1 = () => 100;
// function fun() {
// return 100;
// }
console.log(fun());
let obj = {
name: 'xiaoming',
age: 2,
sayName() {
//let self = this;
// console.log('我是${this.name}');
// console.log('我是' + this.name);
// setTimeout(function () {
// console.log('我是' + self.name);
// }, 500)
setTimeout(() => {
console.log('我是' + this.name);
}, 500)
}
}
obj.sayName();