number to string in typescript code example
Example 1: number to string typescript
var num = new Number(10);
console.log(num.toString());
console.log(num.toString(2));
console.log(num.toString(8));
Example 2: typescript convert an unknown to string
// To convert an unknown type into any other type we can use assertions
let demo: unknown = 'Rice Krispies';
// The above line would throw an error as an unknown variable can
// only take values of unknown and any type
let demo: unknown = 'The EXTRA cripsy colonel...' as string;
// the as string assertion allows us to set an unknown type to a string type
// This can be done with any other variable types it is not
// limited to string
Example 3: typescript parse to string
window.location.hash = ""+page_number;
window.location.hash = String(page_number);