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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:59:33+00:00 2026-06-12T13:59:33+00:00

My goal is to have a object like below: var attrs = { price

  • 0

My goal is to have a object like below:

var attrs = {
    price       : [0, 500000],
    housesize   : [0, 40],
    lotwidth    : [0, 30],
    storeys     : 'both',
    bedroom     : 0,
    bathroom    : 0
};

But I dont want to hard code this and would like to generate automatically from the elements of another object. The object looks like this:

var Defaults = {
      steps             : [10,3,3],                                 // steps for the slider to jump 
      filters           : {
        rangeFilter     : ['price',  'housesize', 'lotwidth'],      // list of slider inputs 
        radioFilter     : ['storeys'],                              // list of radio inputs 
        increamentFilter: ['bedroom', 'bathroom'],
      }
};

So I am trying to build an object whose keys will be all the values of the filters object. The reason I want to do this is because if I add some value to the filters object, I would not need to create a key in attrs object. The numbers of keys in the attrs object is exactly same as the elements in filters object.

Any help would be appreciated. Cheers.

==========================================

******** EDIT ********

This is what I came up with at the moment

var attrs = {};
for (var key in Defaults.filters) {
   var obj = Defaults.filters[key];
   for (var prop in obj) {
      attrs[obj[prop]] = 0; 
   }
}

But at the moment I am adding 0 to all the keys of the new element. I need to come up with a way to add specific values to it dynamically. May be another object inside range filter ??

  • 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-12T13:59:34+00:00Added an answer on June 12, 2026 at 1:59 pm

    I always use this snipped for such tasks:

    function deepCopy(obj) {
    if (Object.prototype.toString.call(obj) === '[object Array]') {
        var out = [], i = 0, len = obj.length;
        for ( ; i < len; i++ ) {
            out[i] = arguments.callee(obj[i]);
        }
        return out;
    }
    if (typeof obj === 'object') {
        var out = {}, i;
        for ( i in obj ) {
            out[i] = arguments.callee(obj[i]);
        }
        return out;
    }
    return obj;
    }
    

    from: http://snipplr.com/view/15407/

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

Sidebar

Related Questions

Let me first describe my goal: I have created an object with 3 properties:
I have the following database table object: public class Goal { @DatabaseField(generatedId = true)
I have a PHP object like so: Array ( [Apples] => stdClass Object (
I have an object like this: <div class=myObject>My Object</div> I want to display a
I have an object roughly like so: class Hand(object): def __init__(self, finger_names, finger_lengths, nail_sizes):
Final goal: Have a few java objects sharing the same base class persisted into
goal: I have the string 1234432144 I want to only replace the first 2
The goal is to have the member variable _AddValue point to the CreateFirstValue function
My goal is to have an Android phone (Samsung Galaxy Nexus) communicate with a
My goal is to have the url routing as following: http://www.abc.com/this-is-peter-page http://www.abc.com/this-is-john-page What is

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.