How to check if a param is true or false?

前端 未结 4 792
我寻月下人不归
我寻月下人不归 2020-12-24 12:10

This is really racking my brain, but maybe I\'m trying to hard.

I\'m passing a param via a URL (example.com?debug=true)

So I basically want to say:



        
4条回答
  •  不知归路
    2020-12-24 12:57

    But for whatever reason that if statement just isn't doing like it seems like it should.

    I can almost guarantee that it is doing exactly what it should. When things don't make sense, one of our assumptions is wrong.

    Is the value actually a boolean or is it string (or something else?). If the value is a string then of course the comparison to the boolean value true will fail. Try comparing to 'true' and see if that works.

提交回复
热议问题