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 |
网友评论