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

  • Home
  • SEARCH
  • 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 5969453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:13:59+00:00 2026-05-22T20:13:59+00:00

my question is probably identical and have same motive as this here i ain’t

  • 0

my question is probably identical and have same motive as this here i ain’t using jQuery. I would like a javascript solution.

my object looks like below:

function Person(name, age, weight) {
    this._name = name;
    this._weight = weight;
    this._age = age;
    this.Anatomy = {
        Weight: this._weight,
        Height: function () {
            //calculate height from age and weight
            return this._age * this._weight;

//yeah this is stupid calculation but just a demonstration
//not to be intended and here this return the Anatomy object
//but i was expecting Person Object. Could someone correct the 
//code. btw i don't like creating instance and referencing it 
//globally like in the linked post
                    }
                }
            }
  • 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-22T20:14:00+00:00Added an answer on May 22, 2026 at 8:14 pm
    this.Anatomy = {
              //'this' here will point to Person
        this.f = function() {
             // 'this' here will point to Anatomy.
        } 
    }
    

    Inside functions this generally points at the next thing up a level. The most consistent way to solve this would be

    this.Anatomy = {
        _person: this,
        Weight: this._weight,
        Height: function () {
            //calculate height from age and weight
            return _person._age * _person._weight;
        }
    }
    

    Alternatively you can do this

    function Person(name, age, weight) {
        this.Anatomy = {
            weight: weight,
            height: function() { return age*weight; }
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question would probably apply equally as well to other languages with C-like multi-line
Probably a long question for a simple solution, but here goes... I have a
This is probably a really simple jQuery question, but I couldn't answer it after
This is probably a really stupid MSBuild question but if I have <ItemGroup> <Dll
This may sound like a very stupid question - and probably is! For an
This question is probably for MySQL experts and admins that have done this sort
This question is nearly identical to this question except that I have to go
This is a question I probably should have asked sooner but didn't in my
This question is probably better phrased: how does running a Java server on a
(This question is over 6 years old and probably no longer has any relevance.)

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.