ES6 destructuring assignment & default value & rename All In One
1.如何使用 js 实现一个 ES6 中 class 的 extends 功能 All In One2.ECMAScript 2023 & Temporal All In One3.js ES5 arguments & arguments.callee & this & ES6 new.target All In One4.ES6 Map Object index All In One5.TypeScript Decorator Metadata All In One6.js ES6 Proxy All In One7.js ES6 Reflect All In One8.js @decorator All In One9.Vue warn All In One10.ES6 解构赋值 All In One11.ES6 & export & export default All In One12.ES6 Async Await bug All In One
13.ES6 destructuring assignment & default value & rename All In One
14.ES6 Symbol All In One15.ES6 Map & WeakMap All In One16.ES6 Reflect All In One17.ES6 Proxy & Reflect All In One18.composition-api & setup19.ES6 Arrow Function & this bug20.ES5 arguments vs ES6 ...rest params All In One21.ES6 export & export.default All In One22.es6 string html23.js create Array ways All In One24.ES6 version repeatify25.es6 curry function26.JavaScript convert ES6 Map to Array All In One27.JavaScript string repeat methods All In One28.ES6 Set All In One29.ES6 Map All In One30.ES6 Arrow Function All In One31.如何用 js 实现一个 ES6 class 类函数 All In One32.ES6 进制字面量 All In One33.redux 中间件 redux-saga 使用教程34.how to convert Map to Object in js35.ES6 Set vs ES5 Array36.ES6 getter & setter37.ES6 arrow function vs ES5 function All In One38.ES6 Class vs ES5 constructor function All In One39.ES6 Generator vs ES6 async/await40.ES6 Map vs ES5 Object All In One41.js swap array42.ES6 ...rest In Action43.Webpack 4.x 默认支持 ES6 语法44.2020 面经(大前端,算法,设计模式,架构)45.js ES5 inheritance All In One46.JavaScript Learning Paths(ES5/ES6/ES-Next)47.ES5 function & ES6 class & method type48.Unicode & \u2028 & \u2029 & ES6 Template literals All In One49.random array & shuffle 洗牌算法 / 随机算法50.js in depth: ES6 destructuring assignment51.gradient text & gradient background52.V8 & ECMAScript & ES-Next53.js 数据劫持 (应用场景) All In One54.ES6 Arrow Function return Object55.ES6 Class & super All In One56.ES6 & tagged-template-literals & template strings All In One57.Enums & JavasScript & TypeScript58.es6 & map & set59.ES6 & import * & import default & import JSON All In One60.vue @ path61.ES6 & Classes & Interface62.ES6 & class extends All In One63.Google Advanced Search operators All In One64.React Native & ES6 & emoji All In One65.ES6 & Map & hashMap66.array to object67.ES6 Set & Map68.ES6 Destructuring Assignment All In One69.vue & lifecycle methods & this bug & ES6 Arrow function & this bind bug70.HTML Imports & polyfill71.yarn & vue-cli & hui-cli All In One72.ES6 Map & WeakMap & ES6 Set & WeakSet73.ES6 polyfills & String.includes() & Array.includes()74.ES6 Arrow Function & this bug75.ES6 Proxies76.ES6 import json77.disable VS Code auto format javascript when save codes78.how to create a javascript components framework using HTML5, CSS3, ES6 All In One79.eslint es6 syntax & object rest spread80.!function() & IIFE81.React.createClass vs. ES6 Class Components82.ES2015 (ES6) 新特性: 20 个ES6 destructuring assignment & default value & rename All In One
const settings = {
speed: 1
};
const {
speed = 1,
width = 100,
} = settings;
console.log(speed);
// 1 - comes from settings object
console.log(width);
// 100 - fallback to default
const person = {
first: 'eric',
// last: undefined,
};
const {
first: firstName,
last: lastName = 'Eric' ,
} = person;
console.log(firstName);
// xgqfrms
console.log(lastName);
// Eric
Because ES6 destructuring assignment default values
only kick in if the value is undefined
✅; null
, false
and 0
are all still values! ❌
const { dogName = '(Snoopy' } = { dogName: undefined }
console.log(dogName);
// what will it be? '(Snoopy'! ✅
const { dogName = 'snickers' } = { dogName: null }
console.log(dogName);
// what will it be? null!
const { dogName = 'snickers' } = { dogName: false }
console.log(dogName);
// what will it be? false!
const { dogName = 'snickers' } = { dogName: 0 }
console.log(dogName);
// what will it be? 0!
refs
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14833391.html
未经授权禁止转载,违者必究!
合集:
ES6
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2020-05-31 Wi-Fi 6
2020-05-31 bind & this & new & arrow function
2020-05-31 HTML5 tags you don't know All In One
2020-05-31 LeetCode 算法题解 & js 大数相加计算解析 All In One
2020-05-31 js function arguments types
2019-05-31 2019 阿里巴巴前端笔试题 All In One
2019-05-31 vue & vue router & dynamic router