Get a Quote Right Now

Edit Template

Parameter de-structuring

Parameter De-structuring: Parameter de-structuring allows you to unpack properties of objects passed as function arguments into local variables within the function body. This can make code more readable and eliminate the need for multiple property accesses.

type ABC = { a: number; b: number; c: number };

function sum({ a, b, c }: ABC) {
console.log(a + b + c);
}

In this example, the sum function receives an object of type ABC, but instead of accessing a, b, and c properties with abc.a, abc.b, and abc.c, you can directly destructure the properties in the parameter list.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *