摘要: sort()方法用in-place的算法对原数组进行排序,但不会产生新的数组。这个方法不是一个稳定的排序,默认采用的是安字符串Unicode码点进行排序的。 let fruit = ['cherries', 'apples', 'bananas']; fruit.sort(); // ['apple 阅读全文
posted @ 2018-06-08 21:22 环球学习机 阅读(182) 评论(0) 推荐(0) 编辑
摘要: find()方法返回数组中第一个满足回调函数测试的第一个元素的值。否则返回undefined const arr1 = [1, 2, 3, 4, 6, 9]; let found = arr1.find(e => e > 5); // 6 参数: 第一个:执行的回调函数 第二个:指定回调函数的thi 阅读全文
posted @ 2018-06-08 21:03 环球学习机 阅读(8330) 评论(0) 推荐(0) 编辑
摘要: filter()方法创建一个新数组,其包含通过回调函数测试的所有元素。 const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present']; const result = words.filter(word 阅读全文
posted @ 2018-06-08 20:55 环球学习机 阅读(449) 评论(0) 推荐(0) 编辑
摘要: Array.from()方法从一个类似数组或可迭代对象中创建一个新的数组实例。 const arr = [1, 2, 3]; Array.from(arr); //[1, 2, 3] Array.from('foo'); // ['f', 'o', 'o'] 参数 第一个:接受一个类数组或可迭代对象 阅读全文
posted @ 2018-06-08 20:46 环球学习机 阅读(3737) 评论(0) 推荐(0) 编辑
摘要: 通过给onclcik包裹一个函数进行上下文的切换与参数的传递: function addClcikEvent(el, fn){ if(el.onclick){ var _back = el.onclik; el.onclick = function(e){ fn.call(this, e); _ba 阅读全文
posted @ 2018-06-08 17:28 环球学习机 阅读(2877) 评论(0) 推荐(0) 编辑
摘要: 1、尽可能减少http请求数量 2、使用CDN 3、添加Expire/Cache-Control头 4、启用Gzip压缩 5、将css放在页面最上 6、将script放在页面最下 7、避免在CSS中使用Expressions 8、把js和css作为独立文件 9、减少DNS查询 10、压缩js和css 阅读全文
posted @ 2018-06-08 15:12 环球学习机 阅读(128) 评论(0) 推荐(0) 编辑