Skip to content

Instantly share code, notes, and snippets.

@gsivaprabu gsivaprabu/parseint.html
Last active May 4, 2017

Embed
What would you like to do?
Confusing string/number with parseInt() Using JavaScript
<!DOCTYPE html>
<html>
<head>
<title> Confusing string/number using JavaScript</title>
<h1 align="center"><u> Confusing string/number with parseInt() Using JavaScript</u></h1>
</head>
<body>
<script type="text/javascript">
// var value = 128;
// var value = 200;
var value = "64e";
console.log('value', valueVal = value);
console.log(typeof(value));
value = parseInt(value, 10);
console.log('value', valueVal = value);
console.log(typeof(value));
if (((/^\d+$/.test(value) && value >= 0 && value <= 128))) {
console.log('true');
} else {
console.log('false');
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.