Open Bug 1346500 Opened 3 years ago

The result of the polyfill doesn't meet the result of firefox.

Categories

(Developer Documentation :: JavaScript, enhancement, P5)

All
Other
enhancement

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: blackmiaool, Unassigned)

References

()

Details

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: 50 Branch
 Technical Contact: 

:: Details

I created a codepen to explain the problem: http://codepen.io/blackmiaool/pen/Vpbava?editors=1111.
The code is like below:
function a() {};
var c = a.bind();


Function.prototype.bind = function(oThis) {
  if (typeof this !== 'function') {
    // closest thing possible to the ECMAScript 5
    // internal IsCallable function
    throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
  }

  var aArgs = Array.prototype.slice.call(arguments, 1),
    fToBind = this,
    fNOP = function() {},
    fBound = function() {
      return fToBind.apply(this instanceof fNOP ?
        this :
        oThis,
        aArgs.concat(Array.prototype.slice.call(arguments)));
    };

  if (this.prototype) {
    // Function.prototype doesn't have a prototype property
    fNOP.prototype = this.prototype;
  }
  fBound.prototype = new fNOP();

  return fBound;
};

var d = a.bind();
console.log(c.prototype,d.prototype);
You need to log in before you can comment on or make changes to this bug.