Using arrow functions with .call()? “This” varies based on if in devtools or iojs locally? Should one avoid using arrows with .call?
问题 I've been running the below code and I notice that when running in devtools, obj.hi = 'default', while when running with iojs 3.3.1 with harmony arrow functions as an arg on my machine, obj.hi = 'foo'. "This" is the window when in devtools, while "this" is the object in iojs. Is it generally good practice to avoid using arrows with .call to avoid this? 'use strict' let obj = { hi: "default" } let foobar = () => { console.log(this) this.hi = "foo" } foobar.call(obj) console.log(obj) 回答1: See