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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:22:58+00:00 2026-06-10T00:22:58+00:00

Possible Duplicate: How is the memory allocation done for variables in scripting languages? In

  • 0

Possible Duplicate:
How is the memory allocation done for variables in scripting languages?

In javascript, since it is a loosely typed language, when I write the code:

var foo;

Exactly after this step how many blocks of memory is allocated. I din assign anything to it and also when I type

var foo = 10;

and

var foo = "this is random"

in both cases how many bytes of memory is allocated?

  • 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-10T00:22:59+00:00Added an answer on June 10, 2026 at 12:22 am

    I’m not sure about the specifics, which are implementation dependent, but here’s what I’d guess.

    Simply doing var foo; doesn’t create any new objects. However, foo might need to be added to a dictionary of declared variables in which case space for the string foo and possible metadata is allocated, assuming it isn’t interned.

    When you do var foo = 10; or var foo = "this is random" it creates string or integer variables respectively, which would normally take up memory. However small ints and constant strings are almost certainly interned. Plus the JIT might optimize away the number reference to a plain machine integer, which case it doesn’t take any extra memory at all.

    Anyway, it’s hard to say much specific about performance in a high level language with varying implementations, especially when a JIT is involved.

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

Sidebar

Related Questions

Possible Duplicate: Javascript memory profiler I like to know what variables take how much
Possible Duplicate: how to find memory leak in c++ code/project I would like to
Possible Duplicate: Objective C Memory Management My code is showing a memory leak here:
Possible Duplicate: does these code has memory leakage?? static private ArrayList seriesColors = new
Possible Duplicate: Array memory allocation - paging Does byte[,] myArray is always in continuous
Please see MSO question A long list of possible duplicates — C memory allocation
Possible Duplicate: Memory overhead of Java HashMap compared to ArrayList I try to search
Possible Duplicate: Limit jvm process memory on ubuntu In my application I'm uploading documents
Possible Duplicate: Linq performance for in-memory collection I have a web application with around
Possible Duplicate: Is there any working memory profiler for Python3 I have some script

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.