In ES6 we can do:
let myFunc = ({name}) => {
console.log(name)
}
myFunc({name:'fred'}) // => logs 'fred'
But how do I do it for nested properties like this:
myFunc({event:{target:{name:'fred'}}}) // => I want it to log 'fred'
What should myFunc look like so that it logs 'fred'?
I cannot change the object passed in. I wish to use destructuring to achieve this or some other suitable ES6 approach.