0

Where are variables stored in javascript when we run pages in the browser?

Also, where I need further insight into memory organisation in terms of javascript variables , usgae and scope, and storage. Like we say in C/C++ : local variables are stored in Stack, Dyanamic memory allocation in Heap area, and program code are stored in program area.

racecarjonathan
  • 1,244
  • 1
  • 11
  • 22
maddy
  • 117
  • 7
  • 1
    [These search results](https://www.google.com/search?q=where+are+javascript+variables+stored&oq=where+are+javascript+&gs_l=serp.3.0.0l3j0i22i30l7.37509384.37512311.0.37513085.21.19.0.2.2.0.269.1745.11j5j1.17.0....0...1c.1.53.serp..2.19.1747.oBuIhY1Ed0I) should answer this question. – Anderson Green Sep 22 '14 at 17:59
  • Also, see this related discussion: http://stackoverflow.com/questions/500431/what-is-the-scope-of-variables-in-javascript – Anderson Green Sep 22 '14 at 18:00
  • i am aware of scope. But can you please tell me about the memory organization . ?????? @AndersonGreen – maddy Sep 22 '14 at 18:23
  • @MayurRahul: The point is that you don't need to care about. Closure scopes need to be stored on the heap, and engines do certain optimisations to store on the stack whatever they can. – Bergi Sep 22 '14 at 18:32
  • The variables are stored on little yellow post-it notes stuck on the refrigerator door. Why do you care exactly? –  Sep 22 '14 at 18:32
  • I am curious to know exactly what happen behind the scene. Just for knowledge purpose. – maddy Sep 22 '14 at 18:47
  • @MayurRahul: It's dependent on the engine. Just imagine that everything goes onto the heap. – Bergi Sep 22 '14 at 19:13
  • OK @Bergi. Still I just want to ask, that engine might be interacting with the CPU resource (for memory storage). rite ?? – maddy Sep 22 '14 at 19:17
  • Well, if you really want to know how a compiler works, you may want to read into the engine code/docs. [They](https://en.wikipedia.org/wiki/List_of_JavaScript_engines)'re mostly open source. – Bergi Sep 22 '14 at 19:39
  • Also see Mike West's [Scope in JavaScript](https://mikewest.org/2006/09/scope-in-javascript). He's active in the W3C standards process and a very good writer. – jww Sep 22 '14 at 21:02
  • @torazaburo: *"Why do you care exactly?"* - I'm not sure it really matters, but here's a for instance... he might be writing WebKit exploits. WebKit makes regular appearances on Bugtraq and Full Disclosure, and its a healthy research target. – jww Sep 22 '14 at 21:05
  • yeah thanks all for giving some direction. I am looking into thoes. – maddy Sep 23 '14 at 05:15
  • Can anyone tell me where Window object is stored ??? – maddy Sep 25 '14 at 05:45

0 Answers0