JSFiddle - React, Tailwind, and code Playground
HTML
<div id="number_conversions"></div>
JavaScript
function write(x){
var element = document.getElementById("number_conversions");
element.innerHTML += x + " <br />";
console.log(x);
}
write('Empty string:');
write('Number("") = ' + Number(""));
write('parseInt("") = ' + parseInt(""));
write('parseFloat("") = ' + parseFloat(""));
write('');
write('Parsing with first lending a letter:');
write('Number("a1") = ' + Number("a1"));
write('parseInt("a1") = ' + parseInt("a1"));
write('parseFloat("a1") = ' + parseFloat("a1"));
write('');
write('Parsing with first lending 1 number:');
write('Number("1a") = ' + Number("1a"));
write('parseInt("1a") = ' + parseInt("1a"));
write('parseFloat("1a") = ' + parseFloat("1a"));
write('');
write('Parsing hexadecimal (10):');
write('Number("0xA") = ' + Number("0xA"));
write('parseInt("0xA") = ' + parseInt("0xA"));
write('parseFloat("0xA") = ' + parseFloat("0xA"));
write('');
write('Lending zeros are ignored:');
write('parseFloat("001") = ' + parseFloat("001"));
write('parseInt("001") = ' + parseInt("001"));
write('Number("001") = ' + Number("001"));
write('');
write('Parsing floating numbers with lending zeros:');
write('parseFloat("00.1") = ' + parseFloat("00.1"));
write('parseInt("00.1") = ' + parseInt("00.1"));
write('Number("00.1") = ' + Number("00.1"));
write('');
write('Parsing floating numbers without lending zeros:');
write('parseFloat("0.1") = ' + parseFloat("0.1"));
write('parseInt("0.1") = ' + parseInt("0.1"));
write('Number("0.1") = ' + Number("0.1"));
write('');
write('Parsing booleans:');
write('Number(true) = ' + Number(true));
write('Number(false) = ' + Number(false));
write('parseFloat(true) = ' + parseFloat(true));
write('parseFloat(false) = ' + parseFloat(false));
write('parseInt(true) = ' + parseInt(true));
write('parseInt(false) = ' + parseInt(false));
write('');
write('Parsing null:');
write('Number(null) = ' + Number(null));
write('parseFloat(null) = ' + parseFloat(null));
write('parseInt(null) = ' +...