With ES6, you can destroy objects in function arguments:
({name, value}) => { console.log(name, value) }
Equivalent to ES5 would be:
function(params) { console.log(params.name, params.value) }
But what if I need a reference to both the object paramsand the attached properties valueand name? This is the closest I got, but the disadvantage is that it will not work with arrow functions, because they do not have access to the object arguments:
function({name, value}) {
const params = arguments[0]
console.log(params, name, value)
}
source
share