Home  >  Article  >  Web Front-end  >  Do you know how to compare numerical values ​​in js?

Do you know how to compare numerical values ​​in js?

烟雨青岚
烟雨青岚forward
2020-07-15 13:24:325642browse

Do you know how to compare numerical values ​​in js?

The var type defined in JavaScript is a weak type, and the default is String type. When comparing the size of two numbers, the default comparison is two strings

You cannot directly use ">" and "2c525f7055eec23eea0e776028c6be894) should be written as

 if(eval(3)>eval(4))
 
var n=4;

if(n>3) should be written as

if(parseInt(n)>eval(3))
 
var n=4;

if(3

if(eval(3)<parseInt(n)&&parseInt(n)<eval(5))

Thank you all for reading, I hope you will benefit from it.

This article is reproduced from: https://blog.csdn.net/CPLASF_001/article/details/89455277

Recommended tutorial: "JS Tutorial"

The above is the detailed content of Do you know how to compare numerical values ​​in js?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete