- Javascript/Typescript:
const n = 1; const s1 = '' + 1; console.log(typeof s1); // string console.log(s1); // '1' const s2 = String(n); console.log(typeof s2); // string console.log(s2); // '1'
- Typescript:
const n = 1; const s1 = <string><any>n; console.log(typeof s1); // string console.log(s1); // '1' const s2 = n as any as string; console.log(typeof s2); // string console.log(s2); // '1'
No comments:
Post a Comment