Home > Web Front-end > JS Tutorial > body text

javascript中比较字符串是否相等的方法_javascript技巧

WBOY
Release: 2016-05-16 17:28:15
Original
1130 people have browsed it

网上看了很多,比如==.equals都不行

还是外国网站给力,发现了方法。
http://stackoverflow.com/questions/2167602/optimum-way-to-compare-strings-in-javascript
用string_a.localeCompare(string_b) 方法去做;它会返回3个值0:字符串相等-1:字符串string_astring_b大家以后就可以使用正确的方法比较字符串了。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!