Some JavaScript Storage Concepts

So we want to store data to be used in a script, what options do we have?

Storing simple values:

If the value is single, such as a string or a number, we can just assign it to a variable.
Normally a variable is a pointer, it points to some data in memory. However, in JavaScript, simple values such as strings and numbers are saved in the variable name location, in other words, the variable points to itself like if it was telling this simple data to “stay here near me, don’t go anywhere, you’re too small to wonder around on your own!“.

Storing complex values:

For more complex data we can use an array which is an ordered list, or we can use a hash, also known as an “object” or an unordered list. I placed “object” in quotes because in reality almost everything is an object in JavaScript. I’d rather call this kind of “objects” unordered lists or key-value paired lists.

Now since this data is more complex, the variable pointer stays on one side of the memory ( the stack), and the data stays on the other side of memory ( the heap). The variable points to the data, it does not hold the data. We can actually have several variables pointing at the same data.

Storing scripts such as functionality:

Now if we want to store a program routine, such as to print or to calculate or to fetch some data, etc. Then we use functions. Like any other object, functions can be moved around and placed inside of other scripts. Functions are also great to isolate one script from another script. Moreover, functions are great to help cleaning up the trash in memory because once returned, a function clears itself out (this cleaning is browser dependent since every browser uses a different kind of broom).

And there you have it. If you want a more in depth explanation please read my eBook
JavaScript Objects Functions and Arrays Explained


Author: tarau

technical writer, web technologies

2 thoughts on “Some JavaScript Storage Concepts”

  1. hi again ,
    i have questions first one is learned java script from but sure they didn’t teach us how to use it in html , now im learning html am i going to learn using java in html now ? or not codecadmy at all ??
    second question is where i can practice ? thanks

  2. Hi there, you’ve got some good questions!
    Keep practicing JavaScript @ Codecademy ( and read my eBooks to expand your awareness of JS)
    As for HTML vs JavaScript, yes, learn as much as you can about HTML and CSS (forget about jQuery for now). Once you feel confident about your HTML skills you can try some of my inexpensive JavaScript project eBooks such as “JavaScript InnerHTML” and “Drawing Six Lucky Numbers”, specially the first one which will give you an introduction on how to mix JavaScript and HTML. Stick to Codecademy, their program is great to keep practicing because in this business if you don’t use it you really lose it. Good luck ahead.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s