javascript - var a = "23" < "3",a为什么是boolean值true?
本文介绍了javascript - var a = "23" < "3",a为什么是boolean值true?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
var a="23" < "3";
console.log(a); // true
console.log(isNaN(a)); // false
偶然遇到的,请帮忙解答,谢谢
解决方案
https://developer.mozilla.org...
C developers have the strcmp() function for comparing strings. In JavaScript, you just use the less-than and greater-than operators:
就是strcmp的规则吧....
两个字符串自左向右逐个字符相比(按ASCII值大小相比较),2<3
这篇关于javascript - var a = "23" < "3",a为什么是boolean值true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文