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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:21:47+00:00 2026-06-17T04:21:47+00:00

i have an object sample data : [Object, Object, Object] 0: Object test_id: 1

  • 0

i have an object sample data:

[Object, Object, Object]
  0: Object
    test_id: "1"
    area: "high"
  1: Object
    test_id: "1"
    area: "saw"
  2: Object
    test_id: "2"
    area: "look"

i am trying to create a new object by grouping by test_id.

var obj = new Object();
$.each(data, function(k, v){
    obj[v.test_id] += {area: v.area};
});

this doesn’t seem to work, it returns only one object line…

i am trying to get something like:

1: {
    {area: "high"}
    {area: "saw"}
}
2: {
    {area: "look""
}

any ideas? thanks

  • 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-17T04:21:48+00:00Added an answer on June 17, 2026 at 4:21 am

    After your edit I notice something, you’re trying to create a javascript object with a property with no name, this is not the format. In JSON (javascript object notation) each property must have a value, what you are trying to store better fits an array.

    Instead, push it into an array

        $.each(data, function(k, v){
        obj[v.test_id].area.push(v.area);
    });
    

    just remember to create obj[v.test_id] first and to set its area property to [].
    This results in:

    1: {
        area: ["high","saw"]
    }
    3: {
        area: ["look"]
    }
    

    Also, if you’re willing to consider using underscore it has very powerful (yet basic) collection methods, you might want to have a look at http://underscorejs.org/#groupBy

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

Sidebar

Related Questions

I have huge amont of geographic data represented in simple object structure consisting only
I have a simple object that allows you to assign three properties (x,y,z) (lets
Say I have a simple object such as class Something { public int SomeInt
Say I have a simple object which supports implicit casting to System.String public sealed
I have a relatively simple object with a method that makes an HTTP request.
I have an object that has pairs of replacement values used for simple encoding
Well, the question is kinda simple. I have a object defined as: public class
I have a String Object in format yyyyMMdd .Is there a simple way to
Currently I have a simple knockoutJS object, with a few observables. But this object
This should be a simple one: I have an observableArray object called To in

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.