![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ES6
tshjy1
IT小白,多多指教,一起学习,共同进步。加油!
展开
-
ES6解构赋值--字符串、数组、对象
**解构赋值规则:**只要等号右边的值不是对象,就先将其转为对象。undefined和null无法转为对象,不能使用解构。 数组解构 // 按顺序解构 const arr = [1, 2, 3] const [a, b, c] = arr a// 1 b// 2 c// 3 // 数组长度解构 const arr = [1, 2, 2, 3, 4, 5, 0] const { length } = arr length// 7 // 默认值解构,能取到值就不取默认值 let [x = 1, y = x]原创 2020-07-14 10:06:34 · 306 阅读 · 0 评论 -
require和import的使用
require和import区别 require和import的使用 require的使用 // const.js module.exports = { a : function() {}, b : 'xxx' }; // test.js const nodeFun = require('./const.js') nodeFun.a() console.log(nodeFun.b) import的使用 // const.js(导出模块) export const aaa = () =>原创 2020-05-26 10:56:11 · 286 阅读 · 0 评论 -
js解构赋值大全
**解构赋值规则:**只要等号右边的值不是对象,就先将器转为对象undefined和null无法转为对象,不能使用解构。 数组解构 // 按顺序解构 const arr = [1, 2, 3] const [a, b, c] = arr a// 1 b// 2 c// 3 // 数组长度解构 const arr = [1, 2, 2, 3, 4, 5, 0] const { length } = arr length// 7 // 默认值解构,能取到值就不取默认值 let [x = 1, y = x]原创 2020-05-18 16:54:51 · 582 阅读 · 0 评论