随笔分类 -  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 阅读全文
posted @ 2025-03-27 15:48 Coca-code 阅读(21) 评论(0) 推荐(0)
摘要:function calculateAssembledSetsAndReturnSkus(suitComponents, inventory) { let componentCount = {}; let minComponent = {}; let result = {}; // Count co 阅读全文
posted @ 2023-12-14 23:29 Coca-code 阅读(28) 评论(0) 推荐(0)
摘要:/**所有程序执行完后执行final();* */ var items = [ 1, 2, 3, 4, 5, 6 ]; var results = []; function async(arg, callback) { console.log('参数为 ' + arg +' , 1秒后返回结果'); 阅读全文
posted @ 2022-03-20 15:42 Coca-code 阅读(32) 评论(0) 推荐(0)
摘要:var items = [ 1, 2, 3, 4, 5, 6 ]; var results = []; function async(arg, callback) { console.log('参数为 ' + arg +' , 1秒后返回结果'); setTimeout(function () { 阅读全文
posted @ 2022-03-20 15:35 Coca-code 阅读(52) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-07-15 13:33 Coca-code 阅读(131) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2018-06-21 21:00 Coca-code 阅读(1119) 评论(0) 推荐(0)
摘要:一. forEach() 二. every 三. some 四. filter 五. map 六. reduce 七. reducerRight (用法与reducer大同) 八. find 九. findIndex 十. Array.keys()、Array.values()、Array.enti 阅读全文
posted @ 2018-06-03 16:32 Coca-code 阅读(204) 评论(0) 推荐(0)
摘要:一. ES7的include 二. Array.of() 三. Array.from() 四. 扩展符 ... 阅读全文
posted @ 2018-06-03 12:58 Coca-code 阅读(454) 评论(0) 推荐(0)
摘要:一. slice 二. join 三. toLocaleString 四. toString 五.concat 六. indexOf 七. lastIndexOf 八. (略,见下篇) 阅读全文
posted @ 2018-06-02 16:34 Coca-code 阅读(179) 评论(0) 推荐(0)
摘要:/*=========================================== 影响原数组,“有味”方法(9个)有: 1. splice() 向/从数组中添加/删除项目 2. sort() 数组排序 3. pop() 删除数组中最后一个元素 4. shift() 删除数组中第一个元素 5. push() 数组最后一个元素添加元素 ... 阅读全文
posted @ 2018-06-02 11:06 Coca-code 阅读(451) 评论(0) 推荐(0)
摘要:/* 因使用“===”,“!==”,结果一致, 便于记忆,也是各大公司推荐规范 */ (function(){ console.log('===== 1 ====='); console.log(false == 'false'); console.log(false == undefined); console.log(false == null); console.log(nul... 阅读全文
posted @ 2018-05-30 02:04 Coca-code 阅读(185) 评论(0) 推荐(0)
摘要:function getViewport(){ if (document.compatMode == "BackCompat"){ return { width: document.body.clientWidth, height: document.body.clientHeight } } else { ... 阅读全文
posted @ 2018-05-30 00:12 Coca-code 阅读(110) 评论(0) 推荐(0)
摘要:/* 摘自微信某前端公众号 如有雷同,纯属巧合 */ function init(arguments){ return new Promise(checkForArgument); } function checkForArgument(resolve, reject){ try{ if(arguments){ return r... 阅读全文
posted @ 2018-05-28 23:02 Coca-code 阅读(118) 评论(0) 推荐(0)
摘要://设置缓存 //name: 缓存key //value: 缓存value //iDay: 缓存过期时间 function setCookie(name, value, iDay){ var oDate = new Date(); oDate.setDate(oDate.getDate() + iDay); document.cookie = name + '=... 阅读全文
posted @ 2018-05-14 08:22 Coca-code 阅读(159) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-03-10 11:04 Coca-code 阅读(194) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2018-02-07 12:25 Coca-code 阅读(116) 评论(0) 推荐(0)
摘要://注意这种形式 function addX(y) { return function(x) { return x + y; } } // 调用 addX(2)(1.5); //3.5 阅读全文
posted @ 2018-01-30 14:04 Coca-code 阅读(84) 评论(0) 推荐(0)
摘要:function gcd(p,q){ if(q == 0){ return p; }else{ var r = p % q; return gcd(q, r); } }; gdc(12,8); //4 阅读全文
posted @ 2017-08-31 08:09 Coca-code 阅读(153) 评论(0) 推荐(0)
摘要:/* *------------------------------------------------------------------------------- * minfengyin@gmail.com 2017-8-29 19:03 *----------------------------------------------------------------------... 阅读全文
posted @ 2017-08-29 19:06 Coca-code 阅读(137) 评论(0) 推荐(0)
摘要:function memoizeFunction(func) { var cache = {}; return function() { var key = arguments[0]; if (cache[key]) { return cache[key]; } else { var ... 阅读全文
posted @ 2017-07-27 11:25 Coca-code 阅读(159) 评论(0) 推荐(0)