By Saheb Sutradhar - Updated On 27-02-2024
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 applications.
Javascript Math.floor(value) method takes a number type value as a parameter and returns the round off of that value. The return value will be the nearest downward integer.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
document.write("Output : " + Math.floor(.60));
</script>
</body>
</html>
Output : 0
Math.floor(value);
Math.floor(.90);
Output : 0
Math.floor(-99.91);
Output : -100
Math.floor(20);
Output : 20
In real-time application, if you have any requirement where the input id is 11.23 and you need to display 11 there you can use javascript Math.floor() method.
This method is supported by most browsers like Chrome, IE, Safari, Firefox etc.
Trending Posts
Create Input Floating Label in CSS and HTML...
CSS Card Hover Effects: Make Your Website Stand Ou...
Create a Rotate Image Gallery with HTML and CSS...
CSS Hover Effect | Web Development...
How to create MongoDB Free cloud Database - Atlas ...
Learn how to create CSS Button RGB Animation...
Create Responsive Sidebar with React JS and tailwi...
Build a JavaScript Carousel Slider With Example...
How to Disable the Submit Button in Formik...
How to Use Bootstrap 5 in Next.js...
codelearningpoint © 2024