Use bind function twice

Viewed 2440

In the [MDN][bind]

We see this code like this

this.x = 9;    // this refers to global "window" object here in the browser
var module = {
  x: 81,
  getX: function() { return this.x; }
};
module.getX(); // 81
var retrieveX = module.getX;
retrieveX();   
// returns 9 - The function gets invoked at the global scope
var boundGetX = retrieveX.bind(module);
boundGetX();

YES,I know the bind will change the "this" value,But I confuse a code below

var demo=boundGetX.bind(this);// or boundGetX.bind(window);
demo();// still 81

Use bind again and I think it will change "this" point to "window",but it is not . I wonder why.

1 Answers
Related