On Oct 7, 5:21 am, atrepp <[EMAIL PROTECTED]> wrote: > Hi, > > I have a problem with Object.isNumber() because it test only for type > number and not for the object Number. > > http://prototype.lighthouseapp.com/projects/8886-prototype/tickets/37... > > 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)); > }, > ====== > > Bug 2http://prototype.lighthouseapp.com/projects/8886-prototype/tickets/37... > > I modified Hash.toQueryString() so it put Number object in the Query > String : > ====== > toQueryString: function() { > return this.inject([], function(results, pair) { > var key = encodeURIComponent(pair.key), values = pair.value; > > if (values && typeof values == 'object') { > if (Object.isArray(values)) > return results.concat(values.map(toQueryPair.curry(key))); > if (Object.isNumber(values)) > return results.push(toQueryPair(key, values.toString())); > } else results.push(toQueryPair(key, values)); > return results; > }).join('&'); > }, > =======
Alex, I have already replied to you on Lighthouse, but, out of curiosity, why do you need `isNumber` to "work" with objects? What's the usecase and why plan type-conversion (before calling isNumber) doesn't satisfy you? > > Cordially, > Alex -- kangax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---
