how do you check if a javascript object is a number or string code example
Example 1: js test if string
if (typeof string === 'string') { /* code */ };
Example 2: javascript check if variable is number
function isNumber(n) {
return !isNaN(parseFloat(n)) && !isNaN(n - 0);
}