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

The Archive Base Latest Questions

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

Which is faster to retrieve information from, an object or a simple calculation? Is

  • 0

Which is faster to retrieve information from, an object or a simple calculation?
Is there a notable difference between them?

Context:

  • Web development
  • Using js and/or jQuery
  • up to hundreds of items affected on a page

Here is a sample of the object I would retrieve information from:

var pModel = {
    1 : {sire: 3, dam: 4, herdList: settings.sireList},
    2 : {sire: 5, dam: 6, herdList: settings.damList},
    3 : {sire: 7, dam: 8, herdList: settings.sireList},
    4 : {sire: 9, dam: 10, herdList: settings.damList},
    5 : {sire: 11, dam: 12, herdList: settings.sireList},
    6 : {sire: 13, dam: 14, herdList: settings.damList}
};

After I wrote the code, I noticed the mathematical pattern inherent in the data:

// Where x is a number
pModel[x].sire == 2x+1;
pModel[x].dam == 2x+2;
(x%2=0) ? settings.damList : settings.sireList;

There are obvious future proofing advantages to using math, but speed is a major consideration here.

  • 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-17T05:08:48+00:00Added an answer on June 17, 2026 at 5:08 am

    At least for math that simple, it turns out math is faster:

    http://jsperf.com/object-vs-calc

    enter image description here

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

Sidebar

Related Questions

Is there any benchmark or comparison which is faster: place nginx in front of
For reading the data from the database which is faster BCP or Data reader?
Looking into selector performance between $('#ID1, #ID2, #ID3') vs $('1X CLASS'). Which is faster?
which one is faster select * from parents p inner join children c on
Which is faster between glob() and opendir() , for reading around 1-2K file(s)?
class TestClass { public void Test() { //which is faster? object o1 = MethodRequiringType(typeof(TestClass));
Possible Duplicate: Regex.IsMatch vs string.Contains Which is faster, preferable and why? What the difference
Which is faster; using event.Invoke(args) , or just calling event(args) . What's the difference?
Which is faster in Java, and why? try { object.doSomething() } catch (NullPointerException e)
Which is faster: Union or Concat ? I don't care about the order of

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.