I am currently developing an Angular application with a code coverage report feature.
There is a method where I need to skip certain lines based on a false condition. So, I attempted to create a function in my component like this:
sum(num1:number,num2:number){
if(1 == 2)
{
//Some Code
}
return num1+num2;
}
However, I encountered an error message stating:
The operator '==' cannot be applied to types '1' and '2'
I noticed that in some cases it allows certain conditions while disallowing others, for example:
if(1 != 2) //not allowed
if(1 == 2) //not allowed
if('1' == '2') //not allowed
if(1===2) //not allowed
if(2 == 2) //allowed
if(2 != 2) //allowed
if('1' == '1') //allowed
if(1===1) //allowed
if(parseInt('1') == parseInt('2')) //allowed
Could someone provide an explanation regarding these scenarios?