JSFiddle - React, Tailwind, and code Playground
JavaScript
// string, float, decimal ou inteiro em javascript
function tipo(nr) {
if (typeof nr == 'string' && nr.match(/(\d+[,.]\d+)/)) return 'string decimal';
else if (typeof nr == 'string' && nr.match(/(\d+)/)) return 'string inteiro';
else if (typeof nr == 'number') return nr % 1 == 0 ? 'numero inteiro' : 'numero decimal';
else return false;
}
var testes = [10, 5.5, '10', '5.5', 'virus'].map(tipo);
console.log(testes);