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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:41:08+00:00 2026-06-07T07:41:08+00:00

Does JavaScript optimize the size of variables stored in memory? For instance, will a

  • 0

Does JavaScript optimize the size of variables stored in memory? For instance, will a variable that has a boolean value take up less space than one that has an integer value?

Basically, will the following array:

var array = new Array(8192);
for (var i = 0; i < array.length; i++)
  array[i] = true;

be any smaller in the computer’s memory than:

var array = new Array(8192);
far (var i = 0; i < array.length; i++)
  array[i] = 9;
  • 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-07T07:41:10+00:00Added an answer on June 7, 2026 at 7:41 am

    Short answer: Yes.

    Boolean’s generally (and it will depend on the user agent and implementation) will take up 4 bytes, while integer’s will take up 8.

    Check out this other StackOverflow question to see how some others managed to measure memory footprints in JS: JavaScript object size

    Edit: Section 8.5 of the ECMAScript Spec states the following:

    The Number type has exactly 18437736874454810627 values, representing the doubleprecision 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic

    … so all numbers should, regardless of implementation, be 8 bytes.

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

Sidebar

Related Questions

var object = {foo: 'bar'}; Does JavaScript have a way to determine that object.foo
Does jquery/javascript have any event model that you can attach to your objects? Basically
I would like to know memory leak in the below mentioned code. Does JavaScript
I'm running a loop in javascript that should take about a minute to complete.
Does JavaScript have a convenient way to test if a variable matches one of
CSS has a @font-face rule which allows us to use custom fonts. Does JavaScript
Does Javascript have a built-in syntax for selecting multiple variables? Say I'd like to
Does JavaScript have the equivalent of the ? : operator that you have in
Does Javascript or jQuery have sometime like the in statement in Python? a in
What does JavaScript pull out with: screen.width and screen.height on the ipad 3? Is

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.