![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JAVAScript
这些年_那份情
这个作者很懒,什么都没留下…
展开
-
查询一个字符串中出现最多的一个字符
function method4_2() { var s = '111122233'; for ( i = 0, z = {}; i < s.length; i++) { z[s.charAt(i)] = (z[s.charAt(i)] || 0) + 1; } t = []; for (e in z) { t[z[e]] ? t[z[e]].push(e) : (t[z[e]]原创 2014-09-05 13:47:16 · 624 阅读 · 0 评论 -
js实现千位分隔符 保留两位小数
function method2() {var s = "1531531.351";if (/[^0-9\.]/.test(s)) {return "invalid value";}s = s.replace(/^(\d*)$/, "$1.");s = (s + "00").replace(/(\d*\.\d\d)\d*/, "$1");s = s.replace(".原创 2014-09-05 13:45:02 · 2314 阅读 · 0 评论 -
把border-left-color转换成BorderLeftColor
function method1() { var str = "border-left-color"; var array = str.split("-"); var newStr = ""; for (var i = 0; i < array.length; i++) { newStr = newStr + (array[i].charAt(0).toUpperCase() + ar原创 2014-09-05 13:47:28 · 1019 阅读 · 0 评论 -
找出数组中最大的数字和位置
function method4_1() { var numArray = [12, 23, 5, 3, 25, 98, 76, 54, 56, 76]; var num = numArray[0]; var position = 0; for (var i = 1; i < numArray.length; i++) { if (numArray[i] > num) { num原创 2014-09-05 13:48:42 · 2586 阅读 · 0 评论