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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:48:40+00:00 2026-06-13T02:48:40+00:00

im having a problem with some code that i have. I have the following

  • 0

im having a problem with some code that i have. I have the following object (bookingDetails) that has a ‘type’ property that is an array, which stores objects, which in turn has another array of objects. for example:

bookingDetails (object)
- type(array)
    - id
    - share (array)
        Number (object)

First off is there a better way to do this? (i need to be able to store numerous ‘Numbers’ against the share per type)

Secondly if someone clicks a big old ‘X’ then i need to delete the number from the correct share and, if the share is empty delete the entire type object that the share belonged to.

at the moment i was trying to do this with the following:

for(var d in bookingDetails[data[6]]){
    var it = bookingDetails[data[6]][d];
    if(it.ID === data[0]){
        for(var s in it.Sharing){
            var pa = it.Sharing[s];
            for(var p in pa){
                var pax = pa[p];
                for(var pd in paxData){
                    if(pax.PaxNo === paxData[pd]){
                        //what to do here??
                    }   
                }
            }
        }
    }
}

i had a look at splice to remove the objects from the share array but this would then change the array indexes which i a problem for the above loops… it all just seems messy.

Any help would be vastly appreciated as i have been trying to do this for a while now..

If this is not the best method of doing this I would love to know of a better way 🙂

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-13T02:48:41+00:00Added an answer on June 13, 2026 at 2:48 am

    Walk the array backwards if you plan on modifying it as you go.

     var i;
     for( i = myarray.length-1; i >= 0; i-- ){
        // ...something that might remove myarray[i]...
     } 
    

    Can’t really speak to your data complexity problem; you may just be trying to represent complex data. It also may be that you should be using objects with named attributes rather than arrays with unnamed indices. Either way, for sanity, I would suggest writing utility functions or even an object decorator to isolate the complexity from other parts of your code.

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

Sidebar

Related Questions

I have some JS code which generates the following object, return { type: some
The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
I'm having a problem with some code that used to work in PHP 4.X
I'm having some problems with deserializing an object. I have following classes: Metadatastore: [DataContract]
I'm having a problem with some code I've written. I've had to anonymize it,
I've having this problem with some JavaScript code. I've simplified it in the error
I am having some problem with jsonp and jquery. This is my code -
I'm building a website and having some problem. if the HTML code is like:
I'm trying to do some refactoring of code, and have run into a problem.
I am currently using the following code to access the property of an object

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.