JavaScript cek jika string adalah nomor
if (typeof myVar === 'string'){
//I am indeed a string
}
Grepper
if (typeof myVar === 'string'){
//I am indeed a string
}
function isNumber(n) {
return !isNaN(parseFloat(n)) && !isNaN(n - 0);
}
function isNumber(value) {
return !isNaN(value) && parseFloat(Number(value)) === value && !isNaN(parseInt(value, 10));
}
The Number. isInteger() method determines whether a
value an integer.
This method returns true if the value is of the type
Number, and an integer (a number without decimals).
Otherwise it returns false.