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 9272161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:48:15+00:00 2026-06-18T15:48:15+00:00

I can use get for individual properties, like this: function MyObjectConstructor() { this._internalValueOne =

  • 0

I can use get for individual properties, like this:

function MyObjectConstructor() {
    this._internalValueOne = 'foo';
    this._internalValueTwo = 'bar';
}

MyObjectConstructor.prototype = {
    get usefulValueOne() {
        return this._internalValueOne + 'baz';
    },
    get usefulValueTwo() {
        return this._internalValueTwo + 'baz';
    }
}

var myObject = new MyObjectConstructor();

Now myObject.usefulValueOne gives 'foobaz' and myObject.usefulValueTwo gives 'barbaz'. Can I somehow use get to make sure that myObject (and any other object based on MyObjectConstructor) also returns an object like {usefulValueOne: 'foobaz', usefulValueTwo: 'barbaz'}? Or is there some other preferred way to do this?

Naturally I also wonder the same thing for set.

  • 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-06-18T15:48:16+00:00Added an answer on June 18, 2026 at 3:48 pm

    you can use this:

    function MyObjectConstructor() {
        this._internalValueOne = 'foo';
        this._internalValueTwo = 'bar';
    }
    
    MyObjectConstructor.prototype = {
        get usefulValueOne() {
            return this._internalValueOne + 'baz';
        },
        get usefulValueTwo() {
            return this._internalValueTwo + 'baz';
        },
        get showProt(){
            var B = {};
            for (var i in this){
                if (i.hasOwnProperty && (i !== 'showProt')){
                    B[i] = this[i];
               }
            }
            return B;
        }
    }
    var myObject = new MyObjectConstructor();
    

    now myObject.showProp will show you an object with all properties (including privates, you should remove them)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which function can I use to get the content of a plain text file?
I know we can use the charAt() method in Java get an individual character
In Python I can use get method to get value from an dictionary without
I can use GetModuleHandle to get its base offset, but I also need to
In an activity we can use getIntent() to get coordinates of top and left
All Hadoop jobs have unique jobid. You can use jobid to get job status
I can use the following to get the contents of a folder with no
How can we use sed to get the 4 characters between Install ID: and
For example to get the favicon of a site I can use http://www.google.com/s2/favicons?domain= and
If I want to get to a value in vector I can use two

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.