上一页 1 2 3 4 5 6 ··· 10 下一页

2022年3月29日

摘要: let res = 'aabbaaaaccdeee'.replace(/(.)\1*/g, '$1'); console.log(res)// abacde 阅读全文
posted @ 2022-03-29 10:02 GameCat 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 方法1 let obj1 = {} let obj2 = {a:1} function func(obj) { for(let key in obj) return false return true } console.log(func(obj1)) console.log(func(obj2)) 阅读全文
posted @ 2022-03-29 09:57 GameCat 阅读(32) 评论(0) 推荐(0) 编辑
摘要: const number = test || 0; 当test值为truthy时,取test的值,否则取0。这样可以避免number被赋为NaN、null、undefined、false等值。 const number = test && test.value; 当test值为truthy时,再去取 阅读全文
posted @ 2022-03-29 09:40 GameCat 阅读(36) 评论(0) 推荐(0) 编辑
摘要: const arr1 = [1,2,3, 3, 2] const getUniqueArray = arr => [...new Set( arr)]; let res = getUniqueArray(arr1) console.log(res) 阅读全文
posted @ 2022-03-29 09:31 GameCat 阅读(576) 评论(0) 推荐(0) 编辑
摘要: (function () { console.log('自执行函数1'); })(); (function () { console.log('自执行函数2'); }()); !function () { console.log('自执行函数3'); }(); + function () { con 阅读全文
posted @ 2022-03-29 09:26 GameCat 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 方法1 let arr1 = [1,2,3] let arr2 = arr1 arr1 = [] console.log(arr1,arr2) // [] [1,2,3] 方法2 const arr1 = [1,2,3] const arr2 = arr1 arr1.length = 0 conso 阅读全文
posted @ 2022-03-29 09:19 GameCat 阅读(42) 评论(0) 推荐(0) 编辑

2022年3月28日

摘要: let arr = [1,2,3,4,5] let max = Math.max.apply(Array, arr) let min = Math.min.apply(Array, arr) console.log(max, min) 阅读全文
posted @ 2022-03-28 22:08 GameCat 阅读(20) 评论(0) 推荐(0) 编辑
摘要: function shuffle(arr) { for(let i = 0; i < arr.length; i++){ let randomIndex = Math.floor(Math.random() * (i + 1)) let item = arr[randomIndex] arr[ran 阅读全文
posted @ 2022-03-28 22:00 GameCat 阅读(67) 评论(0) 推荐(0) 编辑
摘要: function uniqueArr(arr) { return [...new Set(arr.flat(Infinity))] } let str = 'abccccccdddww' console.log(uniqueArr(str.split(''))) let arr = [1, [1, 阅读全文
posted @ 2022-03-28 21:47 GameCat 阅读(23) 评论(0) 推荐(0) 编辑
摘要: let str = 'abccccccdddww' function getType(variable) { return Object.prototype.toString.call(variable).replace(/\[object\s|\]/g, '') } console.log(get 阅读全文
posted @ 2022-03-28 21:22 GameCat 阅读(21) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 10 下一页

导航