首页 > 其他 > 详细

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

时间:2019-01-14 16:51:48      阅读:168      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!