Jump to content

please help on this simple function


SnakesBite101

Recommended Posts

Hmm.....well this is strange...

alert("p" == true);

alerts false, yet:

if ("p") {  alert('true');} else {  alert('false');}

alerts true.... EDIT: Ah, this is the reason (from the same reference I linked above):

if either operand is a string, the other operand is converted to a string if possible.
So in actuality, this:"p" == trueis actually"p" == "true" So, even though "p" is equivalent to true (as evidenced by my second snippet), the == operator treats both sides as if they were strings (when one value is a string) and compares their string values. Edited by ShadowMage
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...