JavaScript不区分大小写的字符串比较 [英] JavaScript case insensitive string comparison

查看:113
本文介绍了JavaScript不区分大小写的字符串比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JavaScript中执行不区分大小写的字符串比较?

How do I perform case insensitive string comparison in JavaScript?

推荐答案

最简单的方法(如果你是不担心特殊的Unicode字符)是调用 toUpperCase

The simplest way to do it (if you're not worried about special Unicode characters) is to call toUpperCase:

var areEqual = string1.toUpperCase() === string2.toUpperCase();

这篇关于JavaScript不区分大小写的字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆