Subj : Re: "x = " vs. "var x = " To : netscape.public.mozilla.jseng From : Lau Lei Cheong Date : Tue Sep 07 2004 03:34 pm I also have this kind of problem, but for most time I simply take away the "var" and then ignore it. This seems a good chance to make it clear. Would you tell my why "var x=5" won't do it? To my understanding "initialize an variable with something" is the same as "declaring the variable, then assign its value with something". Thank a lot. :) "Georg Maaß" ??? news:2q3rudFqq0fpU2@uni-berlin.de ???... > Sterling Bates wrote: > > Just a quick q: why does the expression "var x = 5" return "undefined"? > > This is not an expression. This is a statement, declaring a variable x > initializing it with 5. > > > The expression "x = 5" returns 5, as I would expect. > > This is an expression, not an initialization. > > > -- > Georg Maaß - bioshop.de D-76227 Karlsruhe, Westmarkstraße 82 > HTML, XML / JavaScript, C++, Java, PHP, VB / CGI, JSP, ASP, ASP.net > - The ultimate DHTML engine: http://gml-modul.sourceforge.net - > http://sourceforge.net/projects/gml-modul > .