摘要:
<script> function isEach(arr, callback) { for (var i in arr) { callback(i, arr[i]); } }; function each(arr) { isEach(arr, function(k, v) { console.log 阅读全文
摘要:
<script> function inArray(val, arr) { for (var i = 0, len = arr.length; i < len; i++) { if (arr[i] === val) return i; } return -1; } console.log(inArr 阅读全文
摘要:
<script> function trim(str) { return str.replace(/(^\s*|\s*$)/g, "") } console.log(trim(" 256 ")); console.log(" 123 ".trim()); /* JS str.trim(); JQ $ 阅读全文
摘要:
<script> function sort(arr) { return arr.sort(function(a, b) { return a > b; }) }; console.log(sort([1, 3, 8, 9, 6, 2, 4])); </script> 阅读全文
摘要:
<script> function timer() { setInterval(function() { var date = new Date(), y = date.toLocaleDateString().split("/"), h = date.toLocaleTimeString().su 阅读全文
摘要:
<script> function subArr(a, b) { return a.filter(function(i) { return b.indexOf(i) == -1 }) } console.log(subArr([1,2,3,4],[3,4,5])); </script> 阅读全文
摘要:
<script> function changeFormat(str) { return str.replace(/-(\w)/g, function(k, r) { return r.toUpperCase() }) }; console.log(changeFormat("font-size") 阅读全文
摘要:
<script> function subArr(a, b) { return a.filter(function(i) { return b.indexOf(i) !== -1 }) }; console.log(subArr([1, 2, 3, 4], [3, 4, 5])); </script 阅读全文
摘要:
<script> function subArr(arr) { var obj = {}; return arr.filter(function(n) { return obj[n] ? false : (obj[n] = true) }) } console.log(subArr([1, 2, 3 阅读全文