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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:46:09+00:00 2026-05-23T11:46:09+00:00

For lack of a better title… Is it possible to do something like this

  • 0

For lack of a better title… Is it possible to do something like this in JSON?

var obj = {
            a : 'a constant',
            b : a + ' and b constant'
}

Update: Doesn’t work – this.a returns undefined I know this will work but it looks rather ugly and convoluted:

var obj = {
            a : 'a constant',
            b : (function(){ return this.a + ' and b constant'; })()
}


And here’s what I have currently:

var obj = {
            a : 'a constant',
            b : 'a constant and b constant'
}

I know of the other ways that some have commented upon and I sincerely thank them for responding. However, they don’t look simple or elegant. The only issue I have with my current implementation is that if value of ‘a’ ever gets updated, search-n-replace has to done in many places (I say many because there are more properties that derive from ‘a’) instead of one.

  • 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-23T11:46:10+00:00Added an answer on May 23, 2026 at 11:46 am

    Found a potential solution:

    var obj = {
                a : 'a constant',
                b : obj.a + ' and b constant'
    };
    

    Thanks everyone for their tips! Upvoting all good suggestions.

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

Sidebar

Related Questions

So I have noticed that things (for lack of a better word) like this
Sorry for the lack of a descriptive title; I couldn't think of anything better.
This seems so basic, I'm flabbergasted for lack of a better word. I have
When I click End, it doesn't destroy (lack of a better word) the setTimeout
I would like to remove, edit, or replace this service page (for lack of
For lack of a better name, I'd like to do an izip_sorted in Python.
I have a small issue(for lack of a better word) with MySQL db. I
I have a list of paths (for lack of a better word, maybe bread
I am planning to build, for lack of a better term, a multi user
Due to the lack of documentation for this on MSDN, I am forced to

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.