#375 ✓ resolved
atrepp

Object.isNumber() is false for Number Object

Reported by atrepp | October 7th, 2008 @ 11:17 AM | in 1.6.1

I have a problem with Object.isNumber() because it test only for type number and not for the object Number.

With Webkit (5525.20.1) and Protototype 1.6.0.3 :


var a = new Number(4);
typeof a;
// => "object"
a instanceof Number;
// => true
Object.isNumber(a);
// => false

var b = 4;
typeof b;
// => "number"
b instanceof Number;
// => false
Object.isNumber(b);
// => true

The function should be :


  isNumber: function(object) {
    return typeof ((object == 'number') || (object instanceof Number));
  },

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Referenced by

Pages