I came across some javascript code I don't understand:
what does a < 5 mean if the variable a holds a string?
Thanks
If a holds the string representation of a number, JavaScript will implicitly convert it to a number and perform the comparison.
Otherwise, it will return false.
For example:
var a = 'foo';
(a < 5) // will be false
(a > 5) // will be false
a = '10';
(a < 5) // will be false
(a > 5) // will be true
var a = 'foo' snippet, the string 'foo' gets converted to NaN, and if one of the operands is NaN false is always the result.