JavaScript: Convert a string value of true or false into a boolean

From The Travis van der Font Wiki
Jump to: navigation, search
Method 1:
JSON.parse('true')  === true
JSON.parse('false') === true
Method 2:
/^true$/i.test('true')  === true
/^true$/i.test('false') === false