get length of integer javascript code example

Example 1: check length of number javascript

var number = 773;

number.toString().length;

Example 2: javascript number length

var num = 1234
number.toString().length; // 4

Example 3: javascript number length

export function numberLength(number) {
	let length = 0;
	let n = Math.abs(number);
	do {
		n /= 10;
		length++;
	} while (n >= 1);
	return length;
}

export default numberLength;

Example 4: javascript integer length

var num = 1024,
str = num.toString(),
len = str.length;

console.log(len);