-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
In my project i've found two strange cases with is.Number
function, that i think that's not behaving like it should.
I have a condition like the example underneath, that only accept Numbers, but in fact is.Number
is accepting arrays with numbers or string numbers. I don't think this is the right behavior to handle it, unless it have a good reason for that, that i'm not seeing clearly.
var Util = require( 'findhit-util' );
var array1 = [ "123" ];
var array2 = [ 123 ];
// Example 1
if( Util.is.Number( array1 ) ){
console.log( "array1 it's a number..." );
}else{
console.log( "array1 it's not a number..." );
}
// Example 2
if( Util.is.Number( array2 ) ){
console.log( "array2 it's a number..." );
}else{
console.log( "array2 it's not a number..." );
}
// example 1 console.log -> "array1 it's a number..."
// example 2 console.log -> "array2 it's a number..."
// the cases above should not be a number...
And the Same ( opposite ) thing for isnt.Number
:
// Example 3
if( Util.isnt.Number( array1 ) ){
console.log( "array1 it's not a number..." );
}else{
console.log( "array1 it's a number..." );
}
// Example 4
if( Util.isnt.Number( array2 ) ){
console.log( "array2 it's not a number..." );
}else{
console.log( "array2 it's a number..." );
}
// example 3 console.log -> "array1 it's a number..."
// example 4 console.log -> "array2 it's a number..."
// the cases above should not be a number...
Maybe the proto of the array is assuming the number since the array contains it.
Metadata
Metadata
Assignees
Labels
No labels