Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How can I convert a string to boolean in JavaScript?


ES6+
const string = "false"
const string2 = "true"

const test = (val) => (val === "true" || val === "True")
console.log(test(string))
console.log(test(string2))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #I #convert #string #boolean
ADD COMMENT
Topic
Name
9+5 =