By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

Use of var keyword -- IE 5.2

P: n/a
PJ
Can someone tell me why this works on IE Mac:

uniqueId = (new Date()).getTime() % 10000000;

but this doesn't????

var uniqueId = (new Date()).getTime() % 10000000;

Other instances of the var keyword do not have issues? What gives? TIA~ PJ
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"PJ" <yo*@wish.com> writes:
Can someone tell me why this works on IE Mac:

uniqueId = (new Date()).getTime() % 10000000;

but this doesn't????

var uniqueId = (new Date()).getTime() % 10000000;


Not without seeing the rest of the code.

I *guess* that you refer to a variable called "uniqueId" outside the
scope of this local variable declaration.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
PJ
I *guess* that you refer to a variable called "uniqueId" outside the
scope of this local variable declaration.


That was my first thought, but a change in the variable name does not fix
the issue.
Jul 20 '05 #3

P: n/a
Lee
PJ said:

Can someone tell me why this works on IE Mac:

uniqueId = (new Date()).getTime() % 10000000;

but this doesn't????

var uniqueId = (new Date()).getTime() % 10000000;

Other instances of the var keyword do not have issues? What gives? TIA~ PJ


What do you mean by "works".

If you put the line:

alert(uniqueId);

after both of those, you'll see that they both assign values.
Maybe you don't realize that the "var" keyword makes the variable
local to the function in which it is declared, which means that
it won't be available elsewhere.

The alerts may also show you that, despite being measured in
milliseconds, the clock that drives Date() isn't really updated
that often.

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.