i'm trying to learn javascript destructuring and got stuck, did not find similar to this so im asking if somebody could enlighten me. I have two kind of question 1: here i have destructure in argument ( is it destructure?) and above i have function without destructure it prints {size: 7, radius: 4}25, my question here is why it prints 25 also ? like now it has printed both 'radius's' shoudnt it print just one 'radius(4)' ?
function drawChart(size = 'big', radius = 25 ) {
console.log(size, radius);
}
drawChart({size:7, radius:4} );
2: Now i have put curly braces inside function and there is also curly braces inside argument (which one is destructuring (object destructuring?), both or just above ?), it prints '7 4', now here is not 25, why ?
function drawChart({ size = 'big', radius = 25 } ) {
console.log(size, radius);
}
drawChart({size:7, radius:4} );
if somebody could clarify this i would appreciate it