snippettypescriptCritical
TypeScript: Convert a bool to string value
Viewed 0 times
typescriptboolconvertvaluestring
Problem
I am unable to convert a boolean to a string value in TypeScript.
I have tried to use the
I have tried to use the
toString() method but it does not seem to be implemented on bool.Solution
Updated for comments!
You can now use
This outputs:
And has no errors or warnings.
You can now use
toString() to get a string value from a boolean type.var myBool: boolean = true;
var myString: string = myBool.toString();
console.log(myString);This outputs:
"true"And has no errors or warnings.
Code Snippets
var myBool: boolean = true;
var myString: string = myBool.toString();
console.log(myString);Context
Stack Overflow Q#14774907, score: 210
Revisions (0)
No revisions yet.