This seems like a stupid question. Say I have a function which accepts an object. How can I cast that object as props
, but also destructure props.id
to id
(in the parameter declaration)?
function go ({ id }) {
const props = arguments[0]; // how to do this with destructure?
console.log('props', props, 'id', id);
}
go({id: 2});
props
as an argument thenconst { id } = props;
– Kirmango
function won't receive extra parameters, you can dofunction go(props, {id}=props)
– Baskett