程序员

js类型转换 + decodeURIComponent

2020-09-10  本文已影响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()转换

数据类型 转换为true的 转换为false的
String 任何非空字符串 “”(空字符串)
Number 任何非零数值(包括无穷大) 0和NaN
Object 任何对象 null
undefined -- undefined

3. JavaScript类型转换

image
上一篇 下一篇

猜你喜欢

热点阅读