Another way variables are classified in Javascript are by Scope. i.e. whether the variable is usable only within a function or throughout the whole page.
The two types are
Local Variable
Global Variable
Local Variable
A local variable is one that is declared / Created within a function in Javascript. It is usable only within that function, in other words has a local scope. Such variables are deleted, once the function has been executed.
Global Variable
All the variables that are not declared within a function are called Global variables. Can be used anywhere throughout the page and any function or other code can alter its value i.e. they have a global scope.
The two types are
Local Variable
Global Variable
Local Variable
A local variable is one that is declared / Created within a function in Javascript. It is usable only within that function, in other words has a local scope. Such variables are deleted, once the function has been executed.
Global Variable
All the variables that are not declared within a function are called Global variables. Can be used anywhere throughout the page and any function or other code can alter its value i.e. they have a global scope.
Aucun commentaire:
Enregistrer un commentaire