#375 ✓resolved

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 :

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

var b = 4;
typeof b;
// => "number"
b instanceof Number;
// => false
// => 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


Referenced by