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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:04:15+00:00 2026-06-13T08:04:15+00:00

I’m doing a project in javascript, and need to clarify few things. I’ve read

  • 0

I’m doing a project in javascript, and need to clarify few things. I’ve read that memory management in javascript is not that important since the system does it for us the programmers under the cover, but I’ve also read that sometimes it is good to cache “stuff” for better optimization and so far it is very clear. When we do calculations in a for loop for example
it is better to create a local var and store result in it so we wouldnt have to calculate the same calculation over and over again while going through the loop.
So my question is, I create a json object. Then I want to call it’s property, is it alright to
call it throught the object, like Car.color or to store it in a local var right when I want to access it or something similar. Object = heap, local var = stack as far as I know so does it improve anything or not.

Another example:

   var map = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
              [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];

            if (r >= 0) {
                var num = map[r][k];
                if(num === 0)
                {
                    return false;
                }
            }

Does the num var change anything (for better or worst?), if anyone could expand on this subject that would be nice, 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-13T08:04:16+00:00Added an answer on June 13, 2026 at 8:04 am

    Storing a reference to a thing deep in an object really has nothing to do with memory. It has to do with not having to look up the thing over and over again.

    Storing the value into a variable is like bookmarking a page on the internet. It is there for you to have for future reference. If you do not bookmark it, you need to figure out how in the world you got there and follow the steps over and over again. Bookmark is fast, having to recreate the steps is slow.

    BUT the great news is with the modern day browsers, creating a holding a reference to something does not mean that the code will be faster. In some cases it will be slower! It all depends on the browser, what type of object you are looking up, and what the code is doing.

    • DOM look ups benefit
    • references to a small array/object, not so much.

    Most times you should not really care about it unless you are seeing a major performance bottle neck in your application. That is the point you look at the profile tab in your browser and see where the code is taking forever to run.

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

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I have a small JavaScript validation script that validates inputs based on Regex. I
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.