Skip to content

Instantly share code, notes, and snippets.

@anupj
Created June 29, 2015 11:52
Show Gist options
  • Select an option

  • Save anupj/641fda3d43456e0cc263 to your computer and use it in GitHub Desktop.

Select an option

Save anupj/641fda3d43456e0cc263 to your computer and use it in GitHub Desktop.

Revisions

  1. anupj revised this gist Jun 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // Copied from Effective Javascript (by David Herman
    // Copied from Effective Javascript (by David Herman)
    // Item 31: Prefer Object.getPrototypeOf to __proto__
    // For JS environments that do not provide the ES5 API, it is easy to implement
    // in terms of __proto__
  2. anupj created this gist Jun 29, 2015.
    14 changes: 14 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // Copied from Effective Javascript (by David Herman
    // Item 31: Prefer Object.getPrototypeOf to __proto__
    // For JS environments that do not provide the ES5 API, it is easy to implement
    // in terms of __proto__

    if (typeof Object.getPrototypeOf === "undefined" ) {
    Object.getPrototypeOf = function(obj) {
    var t = typeof obj;
    if (!obj || (t !== "object" && t != "function")) {
    throw new TypeError("not an object");
    }
    return obj.__proto__;
    };
    }