摘要: 1 Function.prototype.bind = function(ctx) { 2 var fn = this; 3 return function() { 4 fn.apply(ctx, arguments); 5 }; 6 }; 1 Promise.myAll = function(pr 阅读全文
posted @ 2021-04-20 01:08 喵喵队立大功 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 举例: 1 <button>按钮</button> 2 3 <script> 4 function throttle(method,context){ 5 clearTimeout(method.tId); 6 method.tId = setTimeout(() => { 7 method.cal 阅读全文
posted @ 2021-04-20 01:03 喵喵队立大功 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 给你单链表的头节点 head ,请你反转链表,并返回反转后的链表。 示例 1: 输入:head = [1,2,3,4,5]输出:[5,4,3,2,1]示例 2: 输入:head = [1,2]输出:[2,1]示例 3: 输入:head = []输出:[] 提示: 链表中节点的数目范围是 [0, 50 阅读全文
posted @ 2021-04-20 00:35 喵喵队立大功 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 第一种:用indexOf方法 这种方法最简单最直观,也最容易理解,代码如下: 1 var arr = [2, 8, 5, 0, 5, 2, 6, 7, 2] 2 var newArr = [] 3 for (var i = 0; i < arr.length; i++) { 4 if (newArr 阅读全文
posted @ 2021-04-20 00:13 喵喵队立大功 阅读(46) 评论(0) 推荐(0) 编辑