May I ask how to understand this deconstruction assignment in ES6?

const add = (state, { payload }) => {
  return state.concat(payload);
};



Sep.29,2021

If the parameter of the
function is a member of the object, the deconstruction assignment takes precedence.
/ / bad
function getFullName (user) {
const firstName = user.firstName;
const lastName = user.lastName;
}
/ / good
function getFullName (obj) {
const {firstName, lastName} = obj;
}
/ / best
function getFullName ({firstName, lastName}) {
}

getting started with ECMAScript 6


two parameters: one is state, the other is an object taking out the value of the payload field in the object and assigning it to the payload variable. The second is an object deconstructing


// .
add(['a','b'], {payload:['c','d']}) // ['a','b','c','d']
.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b168-2c273.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b168-2c273.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?