jquery - Boolean object in javascript returns true for "false" parameter -


i have little problem.

i have situations ajax calss returns string.

sometimes string "false" want convert string value boolean tried : new boolean(thatvalue)

but returns true "false" paremter

is there anyway solve this? except me writing own custom function return false if "flase" ?..

thank you

the best way you've described:

if(value === 'true') {   //do } 

or:

if(value !== 'false') {   //do } 

you're limited javascript's weak typing here, working disadvantage, non-empty string convert true boolean, if string "false".

to , store use elsewhere, works:

var mybool = value !== "false"; 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -