DevilRoshan / Question

前端问题解决
0 stars 0 forks source link

[Daily]以下代码输出结果 #80

Closed DevilRoshan closed 4 years ago

DevilRoshan commented 4 years ago
var length = 10;
function fn() {
  console.log(this.length)
}
var obj = {
  length: 5,
  method: function(fn) {
    fn();
    arguments[0]();
  }
}
obj.method(fn, 1)

function a(xx){
  this.x = xx;
  return this;
}
var x = a(5);
var y = a(6);

console.log(x.x)
console.log(y.x)
DevilRoshan commented 4 years ago

https://github.com/DevilRoshan/Question/blob/master/20200717-js-code-this-2.md