Jump to content
Nate

Comparing Strings

Recommended Posts

I know Java and Javascript are completely different. In Java you need to use methods to compare strings to return a boolean answer. In javascript do you use some type of other method? or just use "==" in an if statement? I don't know if Strings are objects in this script. I'm new to learning and understanding it. Thank you for your help.Nate :)

Share this post


Link to post
Share on other sites
I know Java and Javascript are completely different. In Java you need to use methods to compare strings to return a boolean answer. In javascript do you use some type of other method? or just use "==" in an if statement? I don't know if Strings are objects in this script. I'm new to learning and understanding it. Thank you for your help.Nate :)

== I think:)eg.if ("xxx" == "xx") {alert ('xxx')}if ("xxx" == "xxx") {alert ('xx')}spider

Share this post


Link to post
Share on other sites

Yes you just use ==like:

<head><script type="text/javascript">var test="Hello";if (test=="Hello") alert("hello");else alert("Goodbye");</script></head>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...