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

The Archive Base Latest Questions

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

I have some issues to organize my code. Here is an example of what

  • 0

I have some issues to organize my code.

Here is an example of what i would like to do:

var Test = {
  old: [
    get: function(who, when){
       returrn({ subject: "Old test 001", text: "The test 001 was perform by "+who });
    },
    get: function(who, when){
      returrn({ subject: "Old test 002", text: "The "+when+" the test 002 was performed"});
    }
  ],
  new: [
     //Same thing
  ]
};

The thing is, we apparently can’t do that, so i am wondering which is the way to declare functions in an Array ?
I need to do that because each method get() of the array can return a different message and the message can include the variables passed in parameters at different positions in the text, so i have to declare it explicitly.

I don’t do like this:

var Test = {
  old: [
    one: {
      get: function(who, when){
        returrn({ subject: "Old test 001", text: "The test 001 was perform by "+who });
      },
    },
    two: {
      get: function(who, when){
        returrn({ subject: "Old test 002", text: "The "+when+" the test 002 was performed"});
      }
    }
  ],
  new: [
     //Same thing
  ]
};

Because i need to access the content dynamically, like Test.old[test_id].get("toto", "02/04/2013"). and we unfortunatelly can’t index things by numerical values in JSON.

However i’ll do it like this is there is nothing better.

So what is the best thing to do in this context ?

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-17T09:13:22+00:00Added an answer on June 17, 2026 at 9:13 am

    The question is vague and confusing, but I can see why your code doesn’t work. You’re conflating arrays and objects. Array literals look like this:

    var myArray = [
      "first item",
      "second item",
      {value: "third item"},
      ["first/only item in fourth item"],
      1,
      2,
      3.14159,
      function(a,b) { return a + b; },
      "etc."
    ];
    

    Items in an array are accessed using push, pop, shift, unshift, and numerical indexes.

    Object literal look like this:

    var myObject = {
      one: "some value",
      two: {
        value: "object values can be anything"
      },
      123: 456,
      "a million": function (a, b) { return a - b; }
    };
    

    Items in an object are access using string indexes.

    And finally, do you have a returrn() function declared somewhere? In either case, why not just return your return values?

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

Sidebar

Related Questions

I have some issues with .load : My site use this line of code
I have some issues in setting the classpath for the a project for which
I have some issues with a PHP file that is not working properly. The
I have some issues with my EJB 3 timer where it is launched more
I'm have some issues adding a class to 2 navigation links on a theme.
I seems to have some issues in order to compile gproc from uwiger. I
Im starting with CoCos2d development and I think I have some issues with nodespace,
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I am integrating PayPal in my website But I have some issues in it.
I ran git pull origin and now I have some issues with merge my

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.