How to convert a number type to a string type in TypeScript

How to convert a number type to a string type in TypeScript

To convert a number type to a string type in TypeScript, use ${} for easy conversion.

let a:number = 100;
let b:any = `${a}`; // as ${a}, enclose in backquotes
console.log(typeof b); // displayed as string

Of course, it is possible to change type number to type string as String(a).

コメント

Discover more from 株式会社CONFRAGE ITソリューション事業部

Subscribe now to keep reading and get access to the full archive.

Continue reading

Copied title and URL