javascript - Why does using parseInt on Error return 14? -
consider following:
parseint(new array(), 10); // -> nan parseint(new array(), 16); // -> nan parseint(new error(), 10); // -> nan parseint(new error(), 16); // -> 14 it seems behavior unique error/instances of error. can provide insight?
basically, that's because:
new error().tostring()yields"error", andparseint("error", 16)yields14(because0xe14, parser stops @r).
on other hand, new array() not trigger same behavior because tostring() method of array objects returns contents of array, delimited commas, not class name. therefore, new array().tostring() yields empty string, , parseint() subsequently yields nan.
Comments
Post a Comment