
- TypeScript Tutorial
- TypeScript - Home
- TypeScript - Overview
- TypeScript - Environment Setup
- TypeScript - Basic Syntax
- TypeScript - Types
- TypeScript - Variables
- TypeScript - Operators
- TypeScript - Decision Making
- TypeScript - Loops
- TypeScript - Functions
- TypeScript - Numbers
- TypeScript - Strings
- TypeScript - Arrays
- TypeScript - Tuples
- TypeScript - Union
- TypeScript - Interfaces
- TypeScript - Classes
- TypeScript - Objects
- TypeScript - Namespaces
- TypeScript - Modules
- TypeScript - Ambients
- TypeScript Useful Resources
- TypeScript - Quick Guide
- TypeScript - Useful Resources
- TypeScript - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
TypeScript - Number toFixed()
This method formats a number with a specific number of digits to the right of the decimal.
Syntax
number.toFixed( [digits] )
Parameter Details
digits − The number of digits to appear after the decimal point.
Return Value
A string representation of number that does not use exponential notation and has the exact number of digits after the decimal place.
Example
var num3 = 177.234 console.log("num3.toFixed() is "+num3.toFixed()) console.log("num3.toFixed(2) is "+num3.toFixed(2)) console.log("num3.toFixed(6) is "+num3.toFixed(6))
On compiling, it will generate the same code in JavaScript.
The code will produce the following output −
num3.toFixed() is 177 num3.toFixed(2) is 177.23 num3.toFixed(6) is 177.234000
typescript_numbers.htm
Advertisements