This is a terrible situation.
I want to check whether a number is in given array of numbers. But it returns mysterious result.
Here is my captured console image.
I also check the type of a number and elements in array. Blue one has number type elements, and red one has string type elements. As for a single number, blue number is number type and black number is string type. But the type does not affect anything to the result.
After checking all results, I figured out numbers above 10, double digits, make problems. 1~10 numbers do not make strange situation.
What is the problem? How can I fix this?
Here is my code. This is a part of long code, so I adjust this a little bit to understand seperately.
object = {'2': obj,'3': obj,'10': obj,'11': obj,...}
var array = Object.keys(object);
var newArray = array.map(function(x) {
return parseInt(x, 10)
});
var newNumber = parseInt(number, 10) // number is from above code, just a number.
console.log(newArray);
console.log(newNumber);
console.log(newNumber in newArray);
console.log(array);
console.log(number.toString());
console.log(number.toString() in array);
`