Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] "var" keyword
- From: javascript@xxxxxxxxxx (Peter-Paul Koch)
- Subject: [Javascript] "var" keyword
- Date: Tue, 23 Apr 2002 08:10:49 +0000
>I can declare my variables with the "var" keyord, or not. I can delete a
>variable with "delete" keyword or not. But what is the real diference and
>how should I do?
If you declare a variable inside a function by using the 'var' keyword, it
becomes a local variable:
var theVar = 'global';
function doSomething()
{
alert (theVar) // gives 'global'
var theVar = 'local';
alert (theVar) // gives 'local'
}
As to delete, I never use it and I seem to remember Flanagan said it's not
very important in JavaScript.
ppk
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
- Follow-Ups:
- [Javascript] "var" keyword
- From: Rodney Myers
- [Javascript] "var" keyword
- Prev by Date: [Javascript] locking popups position
- Next by Date: [Javascript] "var" keyword
- Previous by thread: [Javascript] locking popups position
- Next by thread: [Javascript] "var" keyword
- Index(es):