Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10349 (new defect)

Opened 6 months ago

Last modified 5 months ago

[PATCH] [TEST] Object.isNumber(NaN) is evaluated to true

Reported by: mkim Assigned to: sam
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: minor Keywords: discuss
Cc:

Description

Object.isNumber(NaN) is evaluated to true. Currently the isNumber(object) implementation only checks if the object is a type of 'number', need to add an additional check, isFinite(object). Could also use isNaN(object) instead of isFinite(object), but should check for position/negative infinity values as well.

Attachments

isNumber-patch.diff (0.8 kB) - added by mkim on 12/03/07 20:39:19.

Change History

12/03/07 20:39:19 changed by mkim

  • attachment isNumber-patch.diff added.

12/10/07 06:08:21 changed by kangax

  • summary changed from Object.isNumber(NaN) is evaluated to true to [PATCH] [TEST] Object.isNumber(NaN) is evaluated to true.

12/17/07 07:19:24 changed by savetheclocktower

  • keywords set to discuss.
  • severity changed from normal to minor.

Need to get opinions on this. It's a little unintuitive for JavaScript to report NaN as a number, but then I don't know how else to classify it. What's the least surprising thing to do here?

12/17/07 13:44:01 changed by mkim

Since NaN indicates that an object is "Not a Number", I would think that the least surprising thing for Object.isNumber(NaN) is to return false.