码迷,mamicode.com
首页 > 其他好文 > 详细

[Typescript] Improve Readability with TypeScript Numeric Separators when working with Large Numbers

时间:2019-01-14 17:10:23      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:color   type   write   esc   nbsp   rip   form   when   make   

When looking at large numbers in code (such as 1800000) it’s oftentimes difficult for the human eye to quickly see how big the number actually is. TypeScript allows us to use numeric separators to write numbers in a more human readable format (such as 1_800_000), while keeping the generated JavaScript unchanged.

 

Since Typescript 1.7, we are able to do:

const num: number = 123_456_789; // the same as 123456789

 

There is no limit how you add _ to the number, just make it reasonable.

[Typescript] Improve Readability with TypeScript Numeric Separators when working with Large Numbers

标签:color   type   write   esc   nbsp   rip   form   when   make   

原文地址:https://www.cnblogs.com/Answer1215/p/10267710.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!