Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript uses + to convert other types to number types

Shulou Source: shulou.com Published: 2022-06-01 04:39:26 09月22日 Update

This article will explain in detail how JavaScript uses + to convert other types into number types. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Use + to convert other types to number types

Console.log (+ '3.14'); / / = > 3.14console.log (typeof +' 3.14') / / = > numberconst sleep = (milliseconds) = > {return new Promise ((resolve, reject) = > {setTimeout () = > resolve (), milliseconds);} / / of course you can consider using console.time to test! Async function main () {const start = + new Date (); await sleep (3000); const end = + new Date (); console.log (`executed ${end-start} `); / / executed 3002} () This is the end of this article on "how to use JavaScript + to convert other types into number types". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Tags: Type article more good practical content article knowledge reference help related testing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker vpn Xiaomi macOS Microsoft