Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Compare two javascript strings  RSS feed

 
Greenhorn
Posts: 11
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a question?
 
author & internet detective
Posts: 39281
727
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are asking about the syntax for comparing two strings for equality, see this article
 
Greenhorn
Posts: 4
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the answer,


We can use '==' for equal comparision, != for not equal and '====' for strict equal comparision and !== for strict not equal.

strict means in javascript, checking for value and type.
1==='1' are not equal as even though value 1 and '1' are equal but different type number & string.
so 1==='1' will give false.



ask any specific question you have so i can address it
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey ! here you did not mention your question but if you are asking about method for compare two string in javascript then there is the localCompare() method.

The localeCompare() method compares two strings in the current locale.
The localeCompare() method returns a number indicating whether the string comes before, after or is equal as the compareString in sort order.



ex:

 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!