流浪のwolf

卷帝

导航

2022年8月23日

filter 加 indexOf 方法去重数组

摘要: let arr = [1, 2, 3, 4, 3, 2, 3, 4, 6, 7, 6] let unique = (arr) => { console.log(arr) return arr.filter((item, index) => { // console.log(item, index) 阅读全文

posted @ 2022-08-23 18:19 流浪のwolf 阅读(23) 评论(0) 推荐(0) 编辑

把数字转换RMB形式

摘要: 方法1 : var str = '12345679' let strNew = str.replace(/\B(?=(?:\d{3})+\b)/g, ',') // 匹配单词边界替换为逗号 方法2: // 定义一个反转函数反转函数 // 字符串没有直接的反转函数方法 function re(str) 阅读全文

posted @ 2022-08-23 17:18 流浪のwolf 阅读(46) 评论(0) 推荐(0) 编辑

使用 reduce 统计字符串每个字母出现的次数

摘要: // 统计字符串每个字母出现的次数 let str = 'asdfssaaasasasasaa' let obj = str.split('').reduce(function (prev, item) { // prev的初始值是空对象 if (prev[item]) { prev[item]++ 阅读全文

posted @ 2022-08-23 15:37 流浪のwolf 阅读(26) 评论(0) 推荐(0) 编辑

Ajax笔记 3

该文被密码保护。 阅读全文

posted @ 2022-08-23 15:02 流浪のwolf 阅读(4) 评论(0) 推荐(0) 编辑

减少全局变量的使用?使用构造函数和原型对象公用方法函数?

摘要: 把函数挂载到构造函数的原型对象上,可以公用这些函数方法; // 使用函数表达式的方法创建一个构造函数 const OnlyOne = function () {} // 在函数的原型上添加方法 OnlyOne.prototype = { fn1: function () { console.log( 阅读全文

posted @ 2022-08-23 08:53 流浪のwolf 阅读(17) 评论(0) 推荐(0) 编辑