this数组中函数的值是多少methodArray,它是 的属性myObject?另外,是methodArray[0]普通函数还是方法?
let myObject = {
property: "Prakhar",
methodArray: [
function () {
console.log(this);
},
],
};
myObject.methodArray[0]();Run Code Online (Sandbox Code Playgroud)
在浏览器中执行此代码时,它会打印数组。不知道为什么会这样?理想情况下,如果函数不是方法或者myObject函数是方法,则它应该是窗口对象(全局)。