Yes and no.
For the first part, yes , this is essentially what javascript does.
But for the latter, no . Not everything in JavaScript can be converted to a number. For instance:
Number('abc')
And non-A-numbers are not equal:
NaN == NaN // => false
So something like this:
Number('abc') == Number('abc')
But this is really true when comparing equalities.
'abc' == 'abc' // => true
As a side note , it's probably best to use ===in JavaScript, which also checks the type of compared values:
0 == '0' // => true
0 === '0' // => false, because integer is not a string
=== .