javascript
javascript-Global与Math对象
2019獨角獸企業重金招聘Python工程師標準>>>
Global----------------------------------------------------------------
1.encodeURI()和 encodeURIComponent()?decodeURI()和 decodeURIComponent()
encodeURI()不會對本身屬于 URI 的特殊字符進行編碼,例如冒號、正斜杠、問號和井字號;而 encodeURIComponent()則會對它發現的任何非標準字符進行編碼
2.eval
在 eval()中創建的任何變量或函數都不會被提升
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
轉載于:https://my.oschina.net/dajianguo/blog/868705
總結
以上是生活随笔為你收集整理的javascript-Global与Math对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 线程池
- 下一篇: Android使用ViewPager+P