小数点后两位
Math.round(num*100)/100
num.toFixed(2)
(变字符串)
格式化当前时间
mydate=date.toLocaleDateString()
2020/3/5mydate=date.toLocaleDateString().replace(/\//g, '-')
2020-11-28
字符串分割成字符串数组
str.split(",")
str.split(":",3)
字符串截取
3. str.slice(0,3)
abcdefg-> abc
4. str.substring(3)
abcdefg->defg
5. ary.substring(ary.indexOf('e'))
abcdefg->efg
数组转字符串
6. ary.toString()
7. ary.join('/')
数组删除增加
array=[‘a’,‘b’,‘c’,‘d’];
8. array.splice(2,1);
[‘c’] / array:[‘a’,‘b’,‘d’] 删除返回新数组
9. array.splice(2,0,'e');
[’’] / array:[‘a’,‘b’,‘e’,‘c’,‘d’] 增加元素 返回空
10. array.splice(1,1,'ttt')
[‘b’] / array:[‘a’,‘ttt’,‘c’,‘d’]; 增加删除