箭头函数与bind的问题

箭头函数没有自己的this,所以不能通过bind动态地去修改this

var a = {say: function() {
	var fn = (() => {
		console.log(this)
	}).bind(window)
	fn()
}}
a.say() // {say: f}

猜你喜欢

转载自blog.csdn.net/qq_29055201/article/details/90904577
今日推荐