parseInt() Function, JavaScript
You can use the parseInt(), Function from JavaScript to parse a string / variable or other value and get in return an integer.
In the example below, you will see a practical application of this built in Function.
Syntax:
See the example below.
<script type='text/javascript'>
var b='34.54354'
var t='11 at this table.'
document.write('This example uses parseInt() Function and returns' + '<hr>' +parseInt(b) +'<hr>')
document.write('This example does not and returns' + '<hr>' + b +'<hr>')
document.write('This example uses parseInt() Function and returns' + '<hr>' +parseInt(t) +'<hr>')
document.write('This example uses parseInt() Function and returns' + '<hr>' +t)
</script>
In the example below, you will see a practical application of this built in Function.
Syntax:
parseInt("String" or VariableName)
See the example below.
<script type='text/javascript'>
var b='34.54354'
var t='11 at this table.'
document.write('This example uses parseInt() Function and returns' + '<hr>' +parseInt(b) +'<hr>')
document.write('This example does not and returns' + '<hr>' + b +'<hr>')
document.write('This example uses parseInt() Function and returns' + '<hr>' +parseInt(t) +'<hr>')
document.write('This example uses parseInt() Function and returns' + '<hr>' +t)
</script>