Strict Equality Comparison (===) ("strict equality", "identity", "triple equals") : Strict equality compares two values for equality. Neither value is implicitly converted to some other value before being compared. If the values have different types, the values are considered unequal. If the values have the same type, are not numbers, and have the same value, they're considered equal. Otherwise to compare value.
var num = 0;
var str = '0';
console.log(num === str); // false
Abstract Equality Comparison (==) ("loose equality", "double equals") : The behavior for performing loose equality using ==
is as follows. Loose equality compares two values for equality after converting both values to a common type. After conversions (one or both sides may undergo conversions), the final equality comparison is performed exactly as ===
performs it.
var num = 0;
var str = '0';
console.log(num === str); // true
Equality comparisons and sameness
For your problem, it's logic to get those result, because you need to cast value of array :any[] to number and make strict compare.
let categoryIds: any[] = [];
let nrtPatchCategory: number = 30;
// browse categoryIds arrays (you can use any other method like for ...)
categoryIds.forEach(categoryId => {
if (Number(categoryId) === nrtPatchCategory) {
...
}
});
Note: For more detail of forEach() Array.prototype.forEach()
Exemple:
console.log(2 === Number('3')); // false
console.log(3 === Number('3')); // true