Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8012305

Function.bind can't be called on prototype function inside constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 8
    • 8
    • core-libs
    • None
    • b93
    • Verified

      A function defined in an Object prototype is called bind on it in the Object constructor. This is creating a TypeError: Cannot read property "bind" from undefined.
      What is strange is that, if no bind method is called, the method is not undefined and can be called. As soon as bind is called (although being called as the last instruction), method is undefined.

      Testcase:
      function MyObject() { // If the call to bind is removed, then the function is properly printed. print("function " + this._process); this._process = this._process.bind(this); }
      MyObject.prototype._process = function() { print("Message "); }
      var s = new MyObject();

            sundar Sundararajan Athijegannathan
            lagergren Marcus Lagergren
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: