javascript
javascript-Global与Math对象
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
Global----------------------------------------------------------------
1.encodeURI()和 encodeURIComponent()?decodeURI()和 decodeURIComponent()
encodeURI()不會(huì)對(duì)本身屬于 URI 的特殊字符進(jìn)行編碼,例如冒號(hào)、正斜杠、問(wèn)號(hào)和井字號(hào);而 encodeURIComponent()則會(huì)對(duì)它發(fā)現(xiàn)的任何非標(biāo)準(zhǔn)字符進(jìn)行編碼
2.eval
在 eval()中創(chuàng)建的任何變量或函數(shù)都不會(huì)被提升
var msg = "hello world";
eval("alert(msg)"); //"hello world"
3.parseInt parseFloat
parseInt(" 111aaa");//111
Math------------------------------------------------------------------
3.min()和 max()
var max = Math.max(3, 54, 32, 16);
alert(max); //54
var min = Math.min(3, 54, 32, 16);
alert(min); //3
2.舍入方法
Math.ceil Math.floor Math.round
alert(Math.ceil(25.9)); //26
alert(Math.ceil(25.5)); //26
alert(Math.ceil(25.1)); //26
alert(Math.round(25.9)); //26
alert(Math.round(25.5)); //26
alert(Math.round(25.1)); //25
alert(Math.floor(25.9)); //25
alert(Math.floor(25.5)); //25
alert(Math.floor(25.1)); //25
轉(zhuǎn)載于:https://my.oschina.net/dajianguo/blog/868705
總結(jié)
以上是生活随笔為你收集整理的javascript-Global与Math对象的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mysql 线程池
- 下一篇: SpringMVC 简单拦截器配置