math.floor javascript
In this post we are going to learn what is Math.floor() in javascript, how we can use it and when we need to use this in real time application.
Javascript Math.floor(value) method takes a number type value as parameter and returns the round off of that value. The return value will be the nearest downward integer.
Example:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
document.write("Output : " + Math.floor(.60));
</script>
</body>
</html>
Output : 0
Syntax:
Math.floor(value);
Example 1:
Math.floor(.90);
Output : 0
Example 2:
Math.floor(-99.91);
Output : -100
Example 3:
Math.floor(20);
Output : 20
In real time application if you have any requirement where the input id 11.23 and you need to display 11 there you can use javascript Math.floor method.
This method is supported by most of the browsers like Chrome , IE , Safari , Firefox etc.
I hope this article is helpful for you , i am very glad to help you thanks for reading