2020年10月29日
摘要: 一 通过闭包存储 let CPrivate = function(value){ let _private = value; return { getValue:()=> _private, setValue:(value)=> {_private = value} } } 二 通过Symbol创建 阅读全文
posted @ 2020-10-29 18:09 长安城下翩翩少年 阅读(465) 评论(0) 推荐(1) 编辑
摘要: 一 TS2538: Type 'symbol' cannot be used as an index type. ts 中使用 let 定义 Symbol类型值时候会报改错误,将let 改为const 即可。 解析:Symbol的值为不可变的值,故应该定义为常量而不是变量 阅读全文
posted @ 2020-10-29 10:27 长安城下翩翩少年 阅读(346) 评论(0) 推荐(0) 编辑
摘要: 一 只传递一个参数时候 let str = '0123456'; str.slice(5); //'56' str.substr(5); // '56' str.substring(5); // '56' str.slice(-2); // '56' str.substr(-2); // '56' 阅读全文
posted @ 2020-10-29 09:59 长安城下翩翩少年 阅读(485) 评论(0) 推荐(0) 编辑