随笔分类 -  JS

摘要:// 使用工具 fingerprintjs 可以简单取到UUID 1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta http-equiv="X-UA-Compatible" content 阅读全文
posted @ 2024-07-07 17:10 James2019 阅读(38) 评论(0) 推荐(0) 编辑
摘要:1. 放在方法里 const nameToCode = async (nameArr) => { const promiseArr = []; for (const itemName of nameArr) { const promise = new Promise((resolve, reject 阅读全文
posted @ 2022-09-16 19:20 James2019 阅读(56) 评论(0) 推荐(0) 编辑
摘要:let obj = {name: 'lili', age: 21, children: [{name: 'lucy', age: 18}]}let str = JSON.stringify(obj, ["name", "children"]) console.log(str) // '{"name" 阅读全文
posted @ 2022-05-21 23:23 James2019 阅读(263) 评论(0) 推荐(0) 编辑
摘要:之前网上找了个身份证正则,一直用着挺好,直到客户提到 360732202009290611 这个身份证号报警 开始我还不信,网上查这个号码是真的,以下正则替换解决问题 export const checkIDCard = (value: string) => { var num = value.to 阅读全文
posted @ 2022-01-06 11:30 James2019 阅读(1310) 评论(0) 推荐(0) 编辑
摘要:空值合并运算符 name ?? 'Tom' 它是 ES2020 的一个新特性, 只会在左侧表达式是 null 或 undefined 时返回右侧的表达式 不同于逻辑或,空值合并运算符会允许把 0 和 空字符串 '' 作为有效的数值。 必须在配合逻辑或/与(&& ||) 使用时用上括号,否则报错 (f 阅读全文
posted @ 2021-12-17 15:40 James2019 阅读(326) 评论(0) 推荐(0) 编辑
摘要:canvas api 文档:https://www.canvasapi.cn/ 组件里的 canvas <canvas class="handWriting" id="handWriting" canvas-id="handWriting" type="2d" disable-scroll="tru 阅读全文
posted @ 2021-08-04 17:52 James2019 阅读(549) 评论(0) 推荐(0) 编辑
摘要:顾名思义: valueOf 返回其原始值 toString 转为字符串 toLocaleString 转为字符串,为地区特定的格式 (几个示例) 1. Number (1234567).valueOf() // 1234567 数字原始值 (1234567).toString() // "12345 阅读全文
posted @ 2021-05-13 17:28 James2019 阅读(137) 评论(0) 推荐(0) 编辑
摘要:1. js是单线程的,自上而下顺序执行 2. 宏任务 微任务 js里有 seTimeout,setInterval,dom事件,ajax,Promise,process.nextTick(node.js才有的)等函数 Promise和async中的立即执行我们知道Promise中的异步体现在then 阅读全文
posted @ 2021-03-17 21:00 James2019 阅读(1959) 评论(0) 推荐(0) 编辑
摘要:事件冒泡:从一个最具体的的元素接收,然后逐级向上传播 可以形象地比喻为把一颗石头投入水中,泡泡会一直从水底冒出水面。 <ul id="father"> <li class="item1">aaaa</li> <li class="item2">bbb</li> <li class="item3">c 阅读全文
posted @ 2021-03-15 15:37 James2019 阅读(222) 评论(0) 推荐(0) 编辑
摘要:JavaScript是解释型语言,编译一行,执行一行 语法分析 ==》引擎检查你的代码有没有什么低级的语法错误 预编译 =》在内存中开辟一些空间,存放一些变量与函数 变量提升... 解释执行 ==》执行代码 . 阅读全文
posted @ 2021-03-04 18:44 James2019 阅读(73) 评论(0) 推荐(0) 编辑
摘要:面向对象(OOP) VS 函数式编程(FP) PK后 FP略胜出 知呼上有2篇讲的很好: https://zhuanlan.zhihu.com/p/57708956 https://zhuanlan.zhihu.com/p/53762529 阅读全文
posted @ 2021-02-23 11:24 James2019 阅读(331) 评论(0) 推荐(0) 编辑
摘要:限苹果手机,以下自测通过,安卓手机不支持 loadedmetadata <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <input type="fi 阅读全文
posted @ 2021-01-27 15:22 James2019 阅读(1916) 评论(0) 推荐(0) 编辑
摘要:理解 js (function(global){})(window) 参见这里 . 阅读全文
posted @ 2020-12-07 16:36 James2019 阅读(407) 评论(0) 推荐(0) 编辑
摘要:Set 对象作用 数组去重,注意4 ‘4’ 不同 let arr = [1, 2, 3, 4, 4, '4', '4']; let mySet = new Set(arr); [...mySet]; // [1, 2, 3, 4, '4'] 并集 let a = new Set([1, 2, 3]) 阅读全文
posted @ 2020-11-24 19:57 James2019 阅读(78) 评论(0) 推荐(0) 编辑
摘要:新语法: Array(3).fill() // [undefined, undefined, undefined] Array(3).fill(8) // [8, 8, 8] Array(7).fill().map((_, i) => i) // [0, 1, 2, 3, 4, 5, 6] 阅读全文
posted @ 2020-10-12 16:26 James2019 阅读(4333) 评论(0) 推荐(0) 编辑
摘要:取出两个数组中的不同 var arr1 = [0,1,2,3,4,5]; var arr2 = [0,4,6,1,3,9]; function getArrDifference(arr1, arr2) { return arr1.concat(arr2).filter(function(v, i, 阅读全文
posted @ 2020-10-12 16:22 James2019 阅读(2914) 评论(0) 推荐(0) 编辑
摘要:1、js截取两个字符串之间的内容: varstr = "aaabbbcccdddeeefff"; str = str.match(/aaa(\S*)fff/)[1]; console.log(str);//结果bbbcccdddeee 2、js截取某个字符串前面的内容: varstr = "aaa/ 阅读全文
posted @ 2020-07-28 07:43 James2019 阅读(5942) 评论(0) 推荐(0) 编辑
摘要:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol https://www.jianshu.com/p/fd76d308b742 阅读全文
posted @ 2020-07-09 16:51 James2019 阅读(202) 评论(0) 推荐(0) 编辑
摘要:参数默认值 function decimal(num, fix = 2) { return +num.toFixed(fix); } 模板字符串 解构赋值 // 函数入参默认值解构function example({x, y, z = 0}) { return x + y + z; } consol 阅读全文
posted @ 2020-07-08 13:25 James2019 阅读(124) 评论(0) 推荐(0) 编辑
摘要:备注一下这个: https://www.cnblogs.com/wymbk/p/6031442.html 阅读全文
posted @ 2020-04-22 10:27 James2019 编辑

点击右上角即可分享
微信分享提示