DEV Community

Discussion on: Problem with the string 'false'

Collapse
 
lionelrowe profile image
lionel-rowe • Edited

If you know value is either "true" or "false", you can also use JSON.parse(value).

JSON.parse('true') // true
JSON.parse('false') // false
JSON.parse('tru') // SyntaxError: Unexpected token t in JSON at position 0
JSON.parse('"string"') // "string"
Collapse
 
ml318097 profile image
Mehul Lakhanpal

Awesome. Dint know that. I actually faced the issue in query string. Dint realise that it was taking as string 😂🙈