Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:54:23+00:00 2026-05-24T16:54:23+00:00

http://jsbin.com/ifoguf/19/edit I’m unable to access the get area function of Triangle, and getting a

  • 0

http://jsbin.com/ifoguf/19/edit

I’m unable to access the get area function of Triangle, and getting a deprecated error. Google(ed) the Crockford solution to __Proto__, but could use help applying it to the jsbin example.

    function extend(Child, Parent) {
        var F = function () {};
        F.prototype = Parent.prototype;
        Child.prototype = new F();
        Child.prototype.constructor = Child;
        Child.uber = Parent.prototype;
    }
    function extend2(Child, Parent) {
        var p = Parent.prototype;
        var c = Child.prototype;
        for (var i in p) {
            c[i] = p[i];
        }
        c.uber = p;
    }
    var Shape = function () {};
    var TwoDShape = function () {};
    var Triangle = function (side, height) {
        this.side = side;
        this.height = height;
    };
    // agument prototype of Shape;
    Shape.prototype.name = 'shape';
    Shape.prototype.toString = function () {
        return this.name;
    };
    // augment prototype of Triangle;
    Triangle.prototype.name = 'Triangle';
    Triangle.prototype.getArea = function () {
        return this.side * this.height / 2;
    };
    extend2(TwoDShape, Shape);
    extend2(Triangle, TwoDShape);
    var td = new TwoDShape();
    var tri = new Triangle(5, 10);
    alert(tri.__proto__.hasOwnProperty('name'));

   alert(td.name);
   alert(tri.constructor.getArea()); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:54:24+00:00Added an answer on May 24, 2026 at 4:54 pm

    Use Object.getPrototypeOf instead (docs)

    var prot = Object.getPrototypeOf(tri);
    alert(prot.hasOwnProperty('name'));
    

    You would also use that to hit the constructor, so tri.__proto__.constructor is now Object.getPrototypeOf(tri).constructor

    Note that this is not backward compatible with IE<9, so you will still have to use the deprecated method for those browsers. John Resig suggested this as a potential “good enough for now” function to address the lack of user agent support for getPrototypeOf:

    if ( typeof Object.getPrototypeOf !== "function" ) {
      if ( typeof "test".__proto__ === "object" ) {
        Object.getPrototypeOf = function(object){
          return object.__proto__;
        };
      } else {
        Object.getPrototypeOf = function(object){
          // May break if the constructor has been tampered with
          return object.constructor.prototype;
        };
      }
    }
    

    Reference: http://ejohn.org/blog/objectgetprototypeof/

    I find this to be functional, but perhaps a bit over-blown – this is what I use:

    function getProto(obj) {
      return (typeof Object.getPrototypeOf !== 'undefined' ? Object.getPrototypeOf(obj) : obj.__proto__);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsbin.com/ifoguf/14/edit#javascript I attempted Isolating the Inheritance Part into a Function, but when I create
http://jsbin.com/idazeg/edit#javascript,html Can someone tell me how and why this is working? $('#pp').click (function ()
I'm using the code found in this jsbin: http://jsbin.com/asahe5/10/edit There is a function within
http://jsbin.com/ufihev/3/edit Pretty simple code : var t = new function () //line 1 {
How would I fix these errors I get in JSBin? JSBin http://jsbin.com/ebizaj/edit#javascript,html I get
My code : http://jsbin.com/epuxu With help from SO, I managed to get addresses geocoded
Code as reference: http://jsbin.com/aboca3/2/edit In this example above (thank you SLaks) I am truncating
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: I put this snippet of code in jsbin: http://jsbin.com/eneru I am trying to
http://jsbin.com/eyeqer/2/edit var x = document.evaluate('//p/following-sibling::text()', document, null, XPathResult.ANY_TYPE, null); var theTitle = x.iterateNext(); while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.