How do I compare string and boolean in Javascript?

后端 未结 9 1257
长情又很酷
长情又很酷 2020-12-11 01:16

I got the Json \"false\" from server. I respond as bool but it\'s Json so it\'s in browser type is String instead of bool

9条回答
  •  执念已碎
    2020-12-11 01:51

    Try expression data == "true"

    Tests:

    data = "false" -- value will be false

    date = "true" -- value will be true

    Also, fix your JSON. JSON can handle booleans just fine.

提交回复
热议问题