$.isNumeric vs. isNaN

前端 未结 2 1877
日久生厌
日久生厌 2020-12-05 23:46

Is there any difference between $.isNumeric and !isNaN()?

I don\'t see where they will ever return different results.

2条回答
  •  独厮守ぢ
    2020-12-06 00:20

    As PeeHaa says, $.isNumeric() checks whether the value is a number or can be converted to a number, isNaN() checks strictly only whether the value is NaN.

    Here's a handy comparison chart that uses the jQuery documentation's examples (comparing $.isNumeric() to !isNaN for easier comparison): http://jsfiddle.net/eghE9/

提交回复
热议问题