How to Read Object Properties in JavaScript Without Using Dot or Square Brackets.
const calculate = (params) => {
let region = params.region;
let country = params.country;
let name = params.name;
}
As seen in the above code, you can see that we are using the dot notation to read object properties. The above code is fine but we can use object destructuring to shorten the code into a clean single line.
const calculate = (params) => {
const {region, country, name} = params;
}
And even better we can apply object destructuring in the function’s parameter only.
const calculate = ({region, country, name}) => {
}