随笔分类 - JavaScript
摘要:const randomString = () => Math.random().toString(36).slice(2); let result = randomString(); console.log(result);
阅读全文
摘要://注意:末尾的...未计数哟 const truncateString = (string, length) => string.length < length ? string : `${string.slice(0, length)}...`; let result = truncateStr
阅读全文
摘要:注意:仅在浏览器环境下工作 const stripHtml = html => (new DOMParser().parseFromString(html, 'text/html')).body.textContent || ''; let result = stripHtml('<h1>Hi,Pa
阅读全文
摘要:const random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min); let result = random(1, 50); console.log(result);
阅读全文
摘要:const round = (n, d) => Number(`${Math.round(`${n}e${d}`)}e-${d}`); let result1 = round(1.666, 2) let result2 = round(1.888, 2) console.log(result1);
阅读全文
摘要:const reverse = str => str.split('').reverse().join(''); let result = reverse('Panda666'); console.log(result);
阅读全文
摘要:const timeFromDate = date => date.toTimeString().slice(0, 8); let result1 = timeFromDate(new Date(2022, 8, 8, 12, 30, 0)); // 12:30:00 let result2 = t
阅读全文
摘要:const dayOfYear = (date) => Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); let result = dayOfYear(new Date()); console
阅读全文
摘要:const isDateValid = (...val) => !Number.isNaN(new Date(...val).valueOf()); let result = isDateValid("2022-10-10 16:16:00"); // true console.log(result
阅读全文
摘要:const dayDif = (date1, date2) => Math.ceil(Math.abs(date1.getTime() - date2.getTime()) / 86400000); let result = dayDif(new Date("2022-8-10 00:00:00")
阅读全文
摘要:const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1) let result = capitalize("panda") // Panda console.log(result);
阅读全文
摘要:const average = (...args) => args.reduce((a, b) => a + b) / args.length; let result = average(6, 5, 6, 7, 6); // 6 console.log(result);
阅读全文
摘要:确定数字是奇数还是偶数 const isEven = num => num % 2 0; let result = isEven(996); console.log(result);
阅读全文
摘要://方式1: const merge = (a, b) => a.concat(b); //方式2: const merge = (a, b) => [...a,...b]; //测试 let result = merge(['panda','666'],['panda','666']);
阅读全文
摘要:const removeDuplicates = (arr) => [...new Set(arr)]; console.log(removeDuplicates(['p', 'p', 'a', 'n', 'd', 'd', 'a', 6, 6, 6]));
阅读全文
摘要:更新记录 转载请注明出处:https://www.cnblogs.com/cqpanda/p/16589917.html 2022年8月18日 发布。 2022年8月15日 从笔记迁移到博客。 PowerShell介绍(Introduction to PowerShell) 介绍(What is P
阅读全文
摘要:更新记录 2023年3月8日 完善描述内容。 2023年3月6日 修复有错误的地方。 2022年12月29日 更新初始化表单的几种方式 2022年8月18日 发布。 2022年8月13日 从笔记迁移到博客。 ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16
阅读全文
摘要:更新记录 2022年8月17日 发布。 2022年8月13日 从笔记迁移到博客。 ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.html 转载请注明出处:https://www.cnblogs.com/cqpanda/p/16587500.
阅读全文
摘要:更新记录 转载请注明出处:https://www.cnblogs.com/cqpanda/p/16587505.html 2022年8月17日 发布。 2022年8月13日 从笔记迁移到博客。 ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.
阅读全文
摘要:更新记录 转载请注明出处:https://www.cnblogs.com/cqpanda/p/16587398.html 2022年8月16日 发布。 2022年8月13日 从笔记迁移到博客。 ExtJS教程汇总:https://www.cnblogs.com/cqpanda/p/16328016.
阅读全文

浙公网安备 33010602011771号