How to check if type is Boolean

前端 未结 16 1757
深忆病人
深忆病人 2020-12-07 10:09

How can I check if a variable\'s type is of type Boolean?

I mean, there are some alternatives such as:

if(jQuery.type(new Boolean()) === jQuery.type(         


        
16条回答
  •  既然无缘
    2020-12-07 10:49

    if(['true', 'yes', '1'].includes(single_value)) {
        return  true;   
    }
    else if(['false', 'no', '0'].includes(single_value)) {
        return  false;  
    }
    

    if you have a string

提交回复
热议问题