Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Location
    Detroit, Michigan, USA
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript array on storage

    I'd like to create an array that will include data that will be used by several independent and unrelated functions. Is there a way to populate the array and then keep it as some sort of global variable, so that any function can address it with proper qualification?. Thanks in advance.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Javascript array on storage

    This is the general idea. Global variables should be valid from the time the script block runs until the time the page is unloaded.

    <script type="text/javascript">
    var global1 = "This is global up here";
    function doStuff()
    {
    var local1 = "This is local to this function";
    }
    </script>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •