{myadvertisements[zone_1]}
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Starting to Program with JavaScript
#1
When you declare a variable in a function it can be accessed only in that function. (As promised, you will learn about functions shortly.) After the function has run, you cannot call the variable again. Variables in functions are called local variables.

Because a local variable works only within a function, you can have different functions that contain variables of the same name (each is recognized by that function only).

If you declare a variable outside a function, all the functions on your page can access it. The lifetime of these variables starts when they are declared and ends when the page is closed.

Local variables take up less memory and resources than page-level variables because they require only the memory during the time that the function runs, rather than having to be created and remembered for the life of the whole page.
Reply
{myadvertisements[zone_3]}


Possibly Related Threads...
Thread Author Replies Views Last Post
  Qualities for a program to be 100% OOPS language? chinmay.sahoo 0 17 05-24-2017, 10:37 PM
Last Post: chinmay.sahoo

Forum Jump:


Users browsing this thread: 1 Guest(s)
{myadvertisements[zone_2]}