Q:

javascript string and int

I came across some javascript code I don't understand:
what does a < 5 mean if the variable a holds a string?
Thanks

A:

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

