摘要: function fn(n) { if (n 1 || n 2) { return 1; } return fn(n - 1) + fn(n - 2) } 阅读全文
posted @ 2022-10-26 17:07 田心夂 阅读(4) 评论(0) 推荐(0) 编辑
摘要: function FormNuber(number) { let arr = Math.abs(number).toString().split('').reverse() let i = 3 while (i < arr.length) { arr.splice(i, 0, ',') i += 4 阅读全文
posted @ 2022-10-26 17:04 田心夂 阅读(3) 评论(0) 推荐(0) 编辑
摘要: function toUpperCase(str) { let nstr = str.replace(/(?:_)+([^_])/g, function ($0, $1) { return $1.toUpperCase(); }) nstr = nstr.replace(nstr[0], nstr[ 阅读全文
posted @ 2022-10-26 16:58 田心夂 阅读(4) 评论(0) 推荐(0) 编辑
摘要: function toUnderLine(str) { let nstr = str.replace(/[A-Z]/g, function ($0) { return "_" + $0.toLocaleLowerCase(); }) if (nstr.slice(0, 1) == "_") { ns 阅读全文
posted @ 2022-10-26 16:57 田心夂 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 一、写在前面 数组的map方法,其中需要传入两个参数,第一个是一个回调函数,第二个是一个回调函数的this指向的值。 二、手写 在手写map方法时,我们需要注意如下问题。 1、回调函数必须是一个函数 2、调用该方法的对象必须是数组。 3、如果数组的大小为0,则直接返回空数组 Array.protot 阅读全文
posted @ 2022-10-26 16:16 田心夂 阅读(39) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示