Array.prototype.method=function(){ console.log(this.length); } var myArray=[1,2,4,5,6,7] myArray.name="数组" // for (let index in myArray) { // // if (myArray.hasOwnProperty(index)) { // console.log(myArray[index]); // // } // } console.log(Object.keys(myArray)) console.log(myArray['name']) // for (let key of myArray) { // console.log(key) // } const obj = { a: 'a', b: function() {alert(this.a)} } let fn = obj.b fn() // fn 指向 windows