Use Math.round()
:
Math.round(num * 100) / 100
Or to be more specific and to ensure things like 1.005 round correctly, use Number.EPSILON :
Math.round((num + Number.EPSILON) * 100) / 100
Related Contents:
- Formatting a number with exactly two decimals in JavaScript
- Javascript: formatting a rounded number to N decimals
- In jQuery, what’s the best way of formatting a number to 2 decimal places?
- How do you round to 1 decimal place in Javascript?
- How to round float numbers in javascript?
- Get decimal portion of a number with JavaScript
- How can I round down a number in Javascript?
- How can I round a number in JavaScript? .toFixed() returns a string?
- How to round up a number in Javascript?
- Javascript: Round up to the next multiple of 5
- Difference between toFixed() and toPrecision()?
- Rounding numbers to 2 digits after comma
- How can I round to whole numbers in JavaScript?
- JavaScript: Round to a number of decimal places, but strip extra zeros
- Simplest way of getting the number of decimals in a number in JavaScript [duplicate]
- Gaussian/banker’s rounding in JavaScript
- Round a float up to the next integer in javascript
- Truncate/round whole number in JavaScript?
- How to round up a number to a precision of tenths in Javascript?
- How do you round to one decimal place in JavaScript?
- How do I round a number in JavaScript?
- What is the decimal separator symbol in JavaScript?
- Round number up to the nearest multiple of 3
- Is JavaScript guaranteed to be single-threaded?
- What is the shortest function for reading a cookie by name in JavaScript?
- The “unexpected ++” error in jslint [duplicate]
- Handling multiple catches in promise chain
- Vue – Deep watching an array of objects and calculating the change?
- How to clear/remove observable bindings in Knockout.js?
- Throwing strings instead of Errors
- Javascript – Apply trim function to each string in an array
- Replacing callbacks with promises in Node.js
- getAttribute() versus Element object properties?
- Sequelize Where statement with date
- How to make supported on all browsers? Any alternatives?
- What is the difference between enum and object in typescript
- How can I scrape a page with dynamic content (created by JavaScript) in Python?
- split an array into two based on a index in javascript
- Detecting Back Button/Hash Change in URL
- Is Math.random() cryptographically secure?
- How to remove DOM elements without memory leaks?
- React.js: submit form programmatically does not trigger onSubmit event
- JSON forEach get Key and Value
- When using JavaScript’s reduce, how do I skip an iteration?
- Remove leading zeros from input type=number
- Resize Cross Domain Iframe Height [duplicate]
- Removing address bar from browser (to view on Android)
- Vue.js pass function as prop and make child call it with data
- Google Maps v3 API – Auto Complete (address)
- Explain the following JavaScript statement? [duplicate]