随笔分类 - Javascript
做动态网页效果必学的。想Jquery等都是JS。有了Node.js,更为js添加了发挥的舞台。(JS也可以调用底层C)
摘要:let mapBounds = {}; const imageWidth = 800, imageHeight = 600; let targets = []; // Array of moving targets function init(coordinate_lt, coordinate_rb
阅读全文
摘要:function calculateAssembledSetsAndReturnSkus(suitComponents, inventory) { let componentCount = {}; let minComponent = {}; let result = {}; // Count co
阅读全文
摘要:/**所有程序执行完后执行final();* */ var items = [ 1, 2, 3, 4, 5, 6 ]; var results = []; function async(arg, callback) { console.log('参数为 ' + arg +' , 1秒后返回结果');
阅读全文
摘要:var items = [ 1, 2, 3, 4, 5, 6 ]; var results = []; function async(arg, callback) { console.log('参数为 ' + arg +' , 1秒后返回结果'); setTimeout(function () {
阅读全文
摘要:
阅读全文
摘要:const flattenArray = arr => { const flattened = [].concat(...arr); return flattened.some(v => Array.isArray(v))?flattenArray(flattened):flattened; } const arr = [1,[2,3,[3.1,3.2]],4]; c...
阅读全文
摘要:一. forEach() 二. every 三. some 四. filter 五. map 六. reduce 七. reducerRight (用法与reducer大同) 八. find 九. findIndex 十. Array.keys()、Array.values()、Array.enti
阅读全文
摘要:一. ES7的include 二. Array.of() 三. Array.from() 四. 扩展符 ...
阅读全文
摘要:一. slice 二. join 三. toLocaleString 四. toString 五.concat 六. indexOf 七. lastIndexOf 八. (略,见下篇)
阅读全文
摘要:/*=========================================== 影响原数组,“有味”方法(9个)有: 1. splice() 向/从数组中添加/删除项目 2. sort() 数组排序 3. pop() 删除数组中最后一个元素 4. shift() 删除数组中第一个元素 5. push() 数组最后一个元素添加元素 ...
阅读全文
摘要:/* 因使用“===”,“!==”,结果一致, 便于记忆,也是各大公司推荐规范 */ (function(){ console.log('===== 1 ====='); console.log(false == 'false'); console.log(false == undefined); console.log(false == null); console.log(nul...
阅读全文
摘要:function getViewport(){ if (document.compatMode == "BackCompat"){ return { width: document.body.clientWidth, height: document.body.clientHeight } } else { ...
阅读全文
摘要:/* 摘自微信某前端公众号 如有雷同,纯属巧合 */ function init(arguments){ return new Promise(checkForArgument); } function checkForArgument(resolve, reject){ try{ if(arguments){ return r...
阅读全文
摘要://设置缓存 //name: 缓存key //value: 缓存value //iDay: 缓存过期时间 function setCookie(name, value, iDay){ var oDate = new Date(); oDate.setDate(oDate.getDate() + iDay); document.cookie = name + '=...
阅读全文
摘要:1 var a = 00101100, 2 b=11010010; 3 4 a = a^b; 5 b = b^a; 6 a = a^b; 7 8 console.log(a); //11010010
阅读全文
摘要://注意这种形式 function addX(y) { return function(x) { return x + y; } } // 调用 addX(2)(1.5); //3.5
阅读全文
摘要:function gcd(p,q){ if(q == 0){ return p; }else{ var r = p % q; return gcd(q, r); } }; gdc(12,8); //4
阅读全文
摘要:/* *------------------------------------------------------------------------------- * minfengyin@gmail.com 2017-8-29 19:03 *----------------------------------------------------------------------...
阅读全文
摘要:function memoizeFunction(func) { var cache = {}; return function() { var key = arguments[0]; if (cache[key]) { return cache[key]; } else { var ...
阅读全文

浙公网安备 33010602011771号