Can you tell me if it is ok to use string functions on numbers in Javascript? I have a code which needs to do some modifications on string values. Like here:
var value = 0;
if( tableRow.find('input').length )
{
value = tableRow.find('input').val();
}
value = value.replace(/\s/g, '') // Remove spaces
But sometimes value before replace() remains default 0 which is number type. So is it ok to call replace( or other string function ) on the number? It seems it works but I am not sure if all browsers will support it.
EDIT: Not it is not possible. My code works fine because it is always string and condition is not skipped. But variables of number type have NOT .string() function.