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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:34:00+00:00 2026-06-16T00:34:00+00:00

I think there can be a difference between browers, but how do I find

  • 0

I think there can be a difference between browers,

but how do I find out how much memory an array or one element of it takes in Javascript?

I want to figure out how much space I save when using a typed array.

Thanks in advance!

  • 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-16T00:34:01+00:00Added an answer on June 16, 2026 at 12:34 am

    This depends on a wide number of aspects.

    • The length of the reference used to store the variable can vary in size (If you are not using associative arrays, which don’t actually exist in JS, but that’s a different discussion).
    • The item itself can also vary in size. Basically, the binary representation used to store the certain type of object is what makes the memory.
      • An 8 bit int uses 1 byte.
      • A 16 bit int uses 2 bytes.
      • A character in a string uses either 2 or 4 bytes (because of UTF-16).
    • If you want a better insight on size/speed/execution times, I think the only accurate way to go is to use the profiling tools that come with the browser, or use addons like FireBug.

    The reality is different. You shouldn’t worry much about client side storage. Not in this way at least. The only memory specific control you really need is memoization. Other than that, all you need to do is to clean up your traces, so to speak. If you are in an OOP environment, make sure to always delete instance references and null your COM and DOM references once you are done with them.

     

    If you wish to empty a collection (array), simply use the delete operator. If you are not defining the collection as an instance property, but instead you are using var as defining it as a context variable, use myArray.length = 0; which will delete the entire storage in the array.

     

    If you are dealing with large collections, direct assignment is faster than using the Array.prototype.push(); method. myArray[i] = 0; is faster than myArray.push(0); according to jsPerf.com test cases.

     

    The amount of time it takes to iterate over an array can vastly change depending on how you reference the array length, as well as the internet browser you use.

    // Option 1
    for (var i = 0; i < someArray.length; i++) {
        // do something;
    };
    // Option 2
    var l =  myArray.length;
    for(var i = 0; i < l; i++) {
        // do something
    };
    // Option 3
    for (var i = 0, ii = someArray.length; i < ii; i++) {
        // do something;
    };
    

    Test cases for the above are available here.

    As of June 6, 2015, the relative speeds are as follows:

    +--------+------------+---------------+----------------------+
    | Option | Firefox    | Google Chrome | Internet Explorer 11 |
    +--------+------------+---------------+----------------------+
    | 1      | Fastest    | 0.35% Slower  | 46% Slower           |
    | 2      | 21% Slower | 0.15% Slower  | 0.09% Slower         |
    | 3      | 21% Slower | Fastest       | Fastest              |
    +--------+------------+---------------+----------------------+
    

     

    When defining arrays, there is absolutely no point to specify the length, especially if you are doing deferred initialization.

    // Doing this is pointless in JS. It will result in an array with 100 undefined values.
    var a = new Array(100);
    
    // Not even this is the best way.
    var a = new Array();
    
    // Using the array literal is the fastest and easiest way to do things.
    var a = [];
    

    Test cases for array definition are available here.

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

Sidebar

Related Questions

there is one think, i can't understand anyway:((( when i try to set cookie(it
There are plenty of options for powerful server side languages, but I can't think
I'm learning Scala and there is a thing that I can't find out about
I've seen this here and there, but can't find any information regarding this thing.
Is there a difference between method invocation time and method execution time. I think
I didn't think there was a difference between an inputstream object read from a
Well, pretty simple question I think, but I can't find a satisfying answer. Is
I can't help but thing there is a better way of coding the below
i I can not understand one thing.. On my website there is a button
I'm trying to figure out some CIL code. I think there are two statements

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.