Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js check if string is int

function isNumeric(str) {

	// Check if input is string
	if (typeof str != "string")
    	return false

	// Use type coercion to parse the _entirety_ of the string
    // (`parseFloat` alone does not do this).
	// Also ensure that the strings whitespaces fail
	return !isNaN(str) && 
		!isNaN(parseFloat(str)) 
}
 
PREVIOUS NEXT
Tagged: #js #check #string #int
ADD COMMENT
Topic
Name
7+6 =