I have a little problem.
I have situations where my ajax calss return a string.
sometimes this string is "false" I want to always convert this string value to a boolean I tried: new Boolean (thatValue)
but it returns true even for "false" as paremter
Is there anyway to solve this? except that I am writing my own custom function that will return false if "flase"? ..
Thank you
The best way to do this you have already described:
if(value === 'true') { //do something }
Or:
if(value !== 'false') { //do something }
JavaScript, , true boolean, "false".
true
"false"
, - :
var myBool = value !== "false";
, , "". :
thatValue == "false" ? false : true
Source: https://habr.com/ru/post/1756739/More articles:Я пытаюсь создать wx.Frame с переменной прозрачностью (на основе png, отображаемой в событии erase bk) - pythonMySQL Join Query (maybe two internal joins) - joinclearcase: find -name not resolving multiple patterns? - clearcasehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1756737/inheritance-and-pointers-to-pointers-why-doesnt-it-work-and-how-do-i-get-around-it&usg=ALkJrhhA8K9jApC1qjjwev3wmzrQxrAXsQHow does Google Chrome know my current GPS location and how to use it in my code? - google-chromeExtract tar.xz in C / C ++ - c ++How to find out how many OR conditions are met? - sqlWhy are there both utf-16le and utf-16be? efficiency - C - cIs there a way to convert between the type of the Ref parameter and the non-ref version in C # - c #hook_user (): adding an additional field to the database of not only forms - drupal-6All Articles