摘要: console.time('共用时间');function make_pow(n) { return function (x) { return Math.pow(x, n); }}var pow2 = make_pow(2);var pow3 = make_pow(3); console.log( 阅读全文
posted @ 2020-05-15 14:36 Qionghuihe 阅读(3194) 评论(0) 推荐(0) 编辑
摘要: function getQueryString(str, key) { if(str) { var queryString = str.split('?')[1] || ''; var arr = queryString.split('&') || []; for(var i = 0; i<arr. 阅读全文
posted @ 2020-05-12 17:43 Qionghuihe 阅读(720) 评论(0) 推荐(0) 编辑
摘要: var r, arr = ['apple', 'strawberry', 'banana', 'pear', 'apple', 'orange', 'orange', 'strawberry']; r = arr.filter(function (element, index, self) { re 阅读全文
posted @ 2020-05-09 13:45 Qionghuihe 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 'use strict'; function normalize(arr) { var newArr=[]; for(var i=0;i<arr.length;i++){ var temp = arr[i].toLowerCase(); newArr[i] = temp.slice(0,1).toU 阅读全文
posted @ 2020-05-09 10:41 Qionghuihe 阅读(413) 评论(0) 推荐(0) 编辑
摘要: function string2int(s) { function str2num(str){ var strArr = str.split(''); //把字符串分割成字符串数组 function toInt(data){ return +data; //通过js的弱类型转换,实现字符类型到数字类 阅读全文
posted @ 2020-05-08 18:04 Qionghuihe 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 方法一: parseInt([1, 3, 5, 7, 9].join(""));//13579 方法二: var arr = [1, 3, 5, 7, 9];arr.reduce(function (x, y) { return x * 10 + y;});//13579 阅读全文
posted @ 2020-05-08 17:53 Qionghuihe 阅读(514) 评论(0) 推荐(0) 编辑
摘要: 1.for eg:利用for循环计算1 * 2 * 3 * ... * 10的结果: var sum = 1; for(var i = 2;i < 11;i++){ sum *= i; } console.log(sum); 2.for...in... var o = { name: 'Jack', 阅读全文
posted @ 2020-05-08 16:08 Qionghuihe 阅读(216) 评论(0) 推荐(0) 编辑
摘要: Map是一组键值对的结构,具有极快的查找速度。 var m = new Map([['Michael', 95], ['Bob', 75], ['Tracy', 85]]); m.get('Michael'); // 95初始化Map需要一个二维数组,或者直接初始化一个空Map。Map具有以下方法: 阅读全文
posted @ 2020-05-08 15:40 Qionghuihe 阅读(176) 评论(0) 推荐(0) 编辑
摘要: $("#id").attr("disabled","disabled")$("#id").removeAttr("disabled") 阅读全文
posted @ 2020-05-08 15:09 Qionghuihe 阅读(1683) 评论(0) 推荐(0) 编辑
摘要: if (typeof ($("input").attr("required")) != "undefined") { } 阅读全文
posted @ 2020-05-08 15:07 Qionghuihe 阅读(573) 评论(0) 推荐(0) 编辑