每日技术:encodeURI,encodeURIComponent,toFixed

1. encodeURI(URIstring)

encodeURI()函数可把字符串作为URI进行编码

encodeURI("http://www.w3school.com.cn")
//输出 http://www.w3school.com.cn

encodeURI("http://www.w3school.com.cn/My first/")
//输出 http://www.w3school.com.cn/My%20first/

2. encodeURIComponent(URIstring)

encodeURIComponent()函数可把字符串作为URI组件进行编码

encodeURIComponent("http://www.w3school.com.cn")
//输出 http%3A%2F%2Fwww.w3school.com.cn


encodeURIComponent("http://www.w3school.com.cn/p 1/")
//输出 http%3A%2F%2Fwww.w3school.com.cn%2Fp%201%2F

3. toFixed()

toFixed()方法可把Number四舍五入为指定小数位数的数字

var num = new Number(13.37);
num.toFixed(1); // 13.4
原文地址:https://www.cnblogs.com/cathy1024/p/11004094.html