How to determine the number of digits in an integer in JavaScript?

A pure math way to find the number of digits in an integer using Javascript. It works only for positive integers.

let num = 1222; 
const len = Math.log(num) * Math.LOG10E + 1 | 0; 
console.log('The # of digits: ', len); //The # of digits: 4