Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

javascript - 不区分大小写的字符串比较怎么办?(How to do case insensitive string comparison?)

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

  ask by flybywire translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...