Re: function pointers vs direct calling in javascript
- From: getsanjay.sharma@xxxxxxxxx
- Date: Wed, 21 Nov 2007 22:37:20 -0800 (PST)
On Nov 21, 1:13 pm, Randy Webb <HikksNotAtH...@xxxxxxx> wrote:
Told ya you wouldn't believe me :)I believe you. :-)
So you mean there are cases where this would be true? Any examples?Is this so that it doesn't go out to search the
scope tree to look for 'tempVar2' or for some other reason?
That's a possibility, although it isn't in this case.
Here is what I think of 'var', correct me if I am wrong.An detailed explanation with any relevant links would be greatly
appreciated.
Detailed explanation of the use of the var keyword? I am sure there is
one somewhere but I don't have a link to one. The simplest way to
remember it is that using var on a variable name in a function will
*never* alter a global variable. I always use it unless I explicitly
want to alter a global variable from within a function. The only other
time it can come into play is with inner functions and I never use them.
They give me too big a headache and I have never had a use for them.
'var' doesn't as such declare a variable. You don't need 'var' keyword
to *declare* variables or put them in the symbol tree in javascript.
It's just an indication to the scripting engine that 'please put this
variable in a scope which is local to this function. So saying:
var a = 10;
var a = 11;
doesn't actually create two variables or declare two variables but
refer to the same variable both the times which is 'a' which was
declared and defined using the statement 'a = 10'. Thus prepending the
variable name with 'var' separates it from the global namespace
(scope) (assuming we are not using 'with' in which case we would have
an additional scope).
Is this good enough?
Thanks and regards,
/~STS
.
- Follow-Ups:
- Re: function pointers vs direct calling in javascript
- From: RobG
- Re: function pointers vs direct calling in javascript
- From: Randy Webb
- Re: function pointers vs direct calling in javascript
- From: Randy Webb
- Re: function pointers vs direct calling in javascript
- References:
- function pointers vs direct calling in javascript
- From: Sampat
- Re: function pointers vs direct calling in javascript
- From: Randy Webb
- Re: function pointers vs direct calling in javascript
- From: Darko
- Re: function pointers vs direct calling in javascript
- From: Randy Webb
- Re: function pointers vs direct calling in javascript
- From: getsanjay . sharma
- Re: function pointers vs direct calling in javascript
- From: Randy Webb
- function pointers vs direct calling in javascript
- Prev by Date: Re: Valid one time variable assign via var someVar = (this = Object) ? Getvar() : this;
- Next by Date: Re: Valid one time variable assign via var someVar = (this = Object) ? Getvar() : this;
- Previous by thread: Re: function pointers vs direct calling in javascript
- Next by thread: Re: function pointers vs direct calling in javascript
- Index(es):
Relevant Pages
|