Argument Destructuring
Added in ES 2015
Instead of using dot notation to dig into objects, we can destructure the values we need.
var myObject = {
prop1: "Monday",
prop2: "Tuesday"
}
var myFunction = function( object1 ) {
console.log("Property Value: " + object1.prop1);
}
myFunction(myObject); // "Property Value: Monday"
The function could be changed to implement destructuring
var myFunction = function( {prop1} ) {
console.log("Property Value: " + prop1);
}
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext