What is "" in JavaScript really? -


this 1 says false, meaning "" number:

alert(isnan(""));  

this 1 says nan, meaning "" not number , cannot converted:

alert(parsefloat("")); 

i expecting second code convert "" 0 since "" number when tested in isnan wrong! getting crazy or missed something?

parsefloat tries parse number string isnan converts argument number before checking it:

number("") //0 http://ecma-international.org/ecma-262/5.1/#sec-9.3.1 parsefloat("") //nan http://ecma-international.org/ecma-262/5.1/#sec-15.1.2.3 

apparently "broken" or "confusing", specs:

a reliable way ecmascript code test if value x nan expression of form x !== x. result true if , if x nan.

0 !== 0 // false nan !== nan //true  function isexactlynan(x) {     return x !== x; } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -