num
var num=10 num.toFixed(2) //10.00
to.Fixed()指定小数位返回数值的字符串表示
String
chartAt根据字符串位置返回所在位置的字符串
chartCodeAt()根据字符串位置返回所在位置字符串的字符编码
fromChartCode()接收字符编码,转为字符串
concat()将字符串拼接起来得到新的字符串
indexOf()和lastIndexOf() 返回字符串所在的位置
trim()删除空格
toLowerCase()转小写
toUpperCase()转大写
var Str="hello world" str.chartAt(1) //e str.CodeAt(1) //101 fromChartCode(104,101,108108,111) //"hello" var str="hello" str.concat(" world") // "hello world"
slice,substring和substr的区别
slice和substring接收的是起始位置和结束位置,substr接收的是起始位置和所要返回的字符串长度
对于负数,slice会将负数与字符串长度相加,substr会将负的第一个参数加上字符串长度,第二个参数转为0,substring会将所有负数转为0
单体内置对象
Global对象
URI编码方法
encodeURI和encodeURICcomponent encodeURI和decodeURICcomponent **eval的作用 功能是将对于字符串解析出JS代码执行。要避免使用eval,不安全且非常消耗性能
Math对象
min()和max()
var max=Math.max(3,54,32,16); // 54 注意这里不是传入一个数组,而是零散的
舍入方法: Math.ceil() // 向上舍入 Math.floor() // 向下舍入 Math.round() // 四舍五入
生成随机数:random()