美文网首页程序员
js类型转换 + decodeURIComponent

js类型转换 + decodeURIComponent

作者: 塞尔希卡斯 | 来源:发表于2020-09-10 20:14 被阅读0次

    1.decodeURIComponent(URIstring)函数

    URIstring必需。一个字符串,含有编码 URI 组件或其他要解码的文本。
    定义:
    decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。
    例如:

    var test1="http://www.w3school.com.cn/My first/"
    document.write(encodeURIComponent(test1)+ "")
    document.write(decodeURIComponent(test1))
    

    输出:

    http%3A%2F%2Fwww.w3school.com.cn%2FMy%20first%2F
    http://www.w3school.com.cn/My first/
    

    2. Boolean()转换

    • if(condition)的condition求值结果若非布尔值,ECMAScript会自动调用Boolean()转换函数将结果转换为布尔值。转换规则为:
    数据类型 转换为true的 转换为false的
    String 任何非空字符串 “”(空字符串)
    Number 任何非零数值(包括无穷大) 0和NaN
    Object 任何对象 null
    undefined -- undefined

    3. JavaScript类型转换

    image

    相关文章

      网友评论

        本文标题:js类型转换 + decodeURIComponent

        本文链接:https://www.haomeiwen.com/subject/udabsktx.html