Navigate back to the homepage

how to get length of numbers in typescript?

Infinitbility
TypeScript
July 28th, 2022 · 1 min read
how to get length of numbers in typescript?

Get the length of numbers in typescript

To get the length of numbers in typescript, you can use the toString() method with the length property it will return the length of numbers.

1// ✅ Get the length of numbers in typescript
2let num: number = 493054;
3num.toString().length;
4// 👉️ 6

Today, I’m going to show you How do I get the length of numbers in typescript, as above mentioned here, I’m going to use thetoString() method with the length property to get the length of numbers;

Let’s start today’s tutorial how do you get the length of numbers in typescript?

First, I will take the sample number variable, then I will convert it to string and use the length property, let’s console it.

1// ✅ Get length of numbers in typescript
2let num: number = 493054;
3let lenOfNum: number = num.toString().length;
4console.log(lenOfNum)
5// 👉️ 6

I hope it helps you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to get length of object in typescript?

how to get length of object in typescript?

TypeScript, get the length of the object example with a step-by-step guide.

July 28th, 2022 · 1 min read
how to add number to string in typescript?

how to add number to string in typescript?

TypeScript, convert array to string example with a step-by-step guide.

July 27th, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]