: 1. 使用解构赋值: // ES6 const obj = {a: 1, b:2, c:3}; const {a, b, c} = obj; console.log(a,b,c); // 1 2 3 2. 使用展开语法: // ES6 const obj1 = {a: 1, b:2, c:3}; const obj2 = {d: 4, e:5, f:6}; const obj3 = {...obj1, ...obj2}; console.log(obj3); // {a: 1, b:2, c:3, d: 4, e:5, f:6} 3. 使用箭头函数: // ES6 const arr = [1, 2, 3]; const mappedArr = arr.map(item => item * 2); console.log(mappedArr); // [2, 4, 6] 4. 使用rest参数: // ES6 const func = (a, b, ...rest) => { console.log(a, b, rest); } func(1, 2, 3, 4, 5); // 1 2 [3, 4, 5] 5. 使用默认参数: // ES6 const func = (a, b = 10) => { console.log(a, b); } func(1); // 1 10 6. 使用字符串模板: // ES6 const name = 'John'; const greet = `Hello ${name}`; console.log(greet); // Hello John 7. 使用解构赋值: // ES6 const arr = [1, 2, 3]; const [a, b, c] = arr; console.log(a, b, c); // 1 2 3 8. 使用数组的find()方法: // ES6 const arr = [1, 2, 3]; const found = arr.find(item => item === 2); console.log(found); // 2 9. 使用类型判断: // ES6 const type = typeof 10; console.log(type); // number 10. 使用filter()方法: // ES6 const arr = [1, 2, 3, 4, 5]; const filteredArr = arr.filter(item => item % 2 === 0); console.log(filteredArr); // [2, 4]
上一篇: 下一篇:

相关推荐

随机推荐

  1. Qoo10趣天日本广告投标助手
  2. 西西趣天采集插件2.0升级版
  3. 西西电商图片下载助手
  4. 西西趣天韩国批量上货助手最新版
  5. 西西趣天日本批量上货助手最新版
  6. dupeGuru – 电脑重复文件查找工具,支持跨平台使用!
  7. Caesium – 图片批量压缩软件
  8. 7-Zip 免费解压软件
  9. TrayS 绿色免安装版 (任务栏美化工具)
  10. AirDroid 3.7.2.1 Android 设备管家远程控制
  11. Snipaste截图软件下载
  12. Everything 1.4.1.1026 文件搜索工具
  13. chromium浏览器伪造sni工具网页版
  14. 迅雷下载去广告VIP绿色精简最终版11.1.12.1692
  15. 免费听音乐 MusicFree 音乐播放器接口完整版