In JS

1. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

In JS

var abc;<BR>abc = 0;<BR>alert(abc == "");<BR><BR><BR>what do YOU think should pop up?<BR><BR>anyone wanna explain what actually pops up??<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
11,334

I would guess

That it should alert &#039;false&#039;, but since you&#039;re posting it, I&#039;m sure it alerts &#039;true&#039;.<BR><BR>0 and "" are probably treated the same at first. Try <BR><BR>var abc = 10;<BR>alert (abc == "")<BR><BR>and that&#039;ll probably give you false then.

3. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

Oh very good SC

you have shown me how to alert false :p<BR><BR><BR>&#062;0 and "" are probably treated the same at first<BR>at first?? How could they possibly be the same.....<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
11,334

RE: Oh very good SC

&#062;you have shown me how to alert false :p<BR><BR>Huh? I thought that was why you were posting it?<BR><BR>&#062;at first?? How could they possibly be the same.....<BR><BR>How are they different? It&#039;s a VARIANT, which means an uninitalized variant will be 0 or "". So it probably sees them the same. Did you try the example with setting it to 10 instead?<BR><BR><BR>What was the purpose of this exercise? Didn&#039;t you try this out before posting it?<BR>

5. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

Well Einstein

i was wondering WHY it was true...cause we BOTH know 0 is NOT the same as an empty string...basically looking for an explanation<BR><BR><BR>&#062;which means an uninitalized variant will be 0 or ""<BR>ok so if i use parseInt on abc should&#039;nt it return false?<BR><BR>&#062;Didn&#039;t you try this out before posting it?<BR>uh...yes<BR>

6. Senior Member
Join Date
Dec 1969
Posts
11,334

You have to look lower

You may have found a bug, but I can see how it was overlooked... these are all valid statements, no?<BR><BR>var x; //who knows? Null? 0? ""?<BR>x = 0; //a number<BR>x = "hello"; // now a string<BR>x = new Date(); //now a date<BR>x = Server.CreateObject.. //now an object<BR><BR>Well, when the engine turns the thing into a new type, it has to initialize it to something. Maybe they have some sort of glitch?<BR><BR>Ooh, this returns true as well...<BR><BR>alert(0 == "");<BR><BR>Perhaps it has nothing to do with the variable then? <BR><BR>Why are you making me think so late in the day? It&#039;s cause I&#039;m not on Pacific time and you&#039;re around longer to torture me :p<BR><BR>

7. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

Ya know i was JUST coming back

to throw that at ya and ask you to put that in your pipe and smoke it<BR><BR><BR>i tried the 0 == "" and it lays to waste your "theory"<BR><BR>&#062;Why are you making me think so late in the day?<BR>comon you have to start sometime in your life :p<BR><BR><BR><BR>i got to packages sent out....only the oldies are left.....should have it out by the end of this week....you MAY need some brass polish....maybe i should open it and see how badly the brass tarnished......hmmm does brass tarnish....i know silver does...what does brass do then...lets leave it at tarnish.....dotn think i will open it up though....too much of a headache to pack it again<BR><BR><BR><BR><BR><BR>

8. Senior Member
Join Date
Dec 1969
Posts
11,334

Heh

Gots plenty of polish.<BR><BR>Dunno what to tell you about 0 == "". Are you that bored at work that you&#039;re just throwing things into alert boxes?<BR><BR>Well, I&#039;m outta for today. See yas tomorrow.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•