DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

JavaScript String Comparison

02.09.2007
| 67187 views |
  • submit to reddit
        // Example use
// if (isSameString(tags, "_none_")) ...

      function isSameString( s1, s2 )
      {
        alert( "s1: " + s1.toString() );
        alert( "s2: " + s2.toString() );

      	if ( s1.toString() == s2.toString() )
        {
      	  return true;
        }
        else
        {
          return false;
        }
      }
    

Comments

Snippets Manager replied on Tue, 2009/09/29 - 4:59pm

Probably return (s1.toString() == s2.toString()); would do the same.