ShadowMage Posted June 22, 2012 Share Posted June 22, 2012 (edited) 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 June 22, 2012 by ShadowMage Link to comment Share on other sites More sharing options...
eTianbun Posted June 22, 2012 Share Posted June 22, 2012 Lol... Very Funny! Link to comment Share on other sites More sharing options...
ShadowMage Posted June 22, 2012 Share Posted June 22, 2012 Lol... Very Funny!Indeed. :PI learned something today. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now