You are checking whether the variable rowind
is equal to empty string in your condition.
((rowind == '')) // this will return as false since you variable is not an empty string. Rather it contains a string with 0 character
if you want to compare the string, use the following.
((rowind == '0')) //This will return true since the string is as same as the variable.
Update
The question you are asking is related to javascript type casting.
The MDN Doc
Equality (==)
The equality operator converts the operands if they are not of the same > type, then applies strict comparison. If both operands are objects, then > JavaScript compares internal references which are equal when operands > refer to the same object in memory.
The above explains how the ==
operator works in javaascript.
In your example, the ''
is converted to a number since it is being compared with a type number variable. so javascript treats ''
as a number and ''
is equal to 0. thus returns true in your condition.
console.log(0 == '0'); //True
console.log(0 == ''); //True
console.log('' == '0'); //False
The following is the strict comparison
used as an example.
console.log(3 == '3') //True
console.log(3 === '3') //False