12 2020 档案

摘要:函数参数解构 function sayHi({ name, age }: any) { console.log(`Hi, ${name}, ${age}`); } sayHi({ name: 'ANDY', age: 18 }); 阅读全文
posted @ 2020-12-11 11:51 liaoing 阅读(55) 评论(0) 推荐(0)
摘要:优雅编程 1 判断不是空数组,做一些事情 // bad if (arr.length !== 0) { // todo } // good if (arr.length) { // todo } 2 使用includes简化if判断 // bad if (a 1 || a 2 || a 3 || a 阅读全文
posted @ 2020-12-09 15:25 liaoing 阅读(114) 评论(0) 推荐(0)
摘要:转成布尔值 1.通过!!转换 2.通过Boolean( ) ⭐️ 注:undefined,null,-0,+0,NaN,‘’(空字符串)是false,其他的都是true。 所有对象的布尔值都是true,甚至连false对应的布尔对象也是true。空对象和空数组[]也会被转成true。 number类 阅读全文
posted @ 2020-12-09 14:53 liaoing 阅读(188) 评论(0) 推荐(0)
摘要:const obj = 1.toString(推荐) Object.prototype.toString.call(obj) '[object Object]' 2.constructor obj.constructor Object obj?.constructor Object 3.instan 阅读全文
posted @ 2020-12-09 14:09 liaoing 阅读(13090) 评论(0) 推荐(0)