Home >Web Front-end >JS Tutorial >Method to compare whether strings are equal in javascript_javascript skills

Method to compare whether strings are equal in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:28:151214browse

I read a lot on the Internet, for example, ==.equals didn’t work

It was because of the help of foreign websites that I found a method.
http://stackoverflow.com/questions/2167602/optimum-way-to-compare-strings-in-javascript
Use the string_a.localeCompare(string_b) method to do it; it will return 3 values ​​of 0: String equality -1: String string_astring_b You can use the correct method to compare strings in the future.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn