Destructuring assignment in function call while preserving the object

Viewed 5791

Is there a way to do something like the following?

f = (o:{a:x}) {
    console.log(o);
    console.log(x);
}
f({a:0});
//Should Print:
//{a:0}
//0

To get the same result as the this.

f = function(o) {
    var {a:x} = o;
    console.log(o);
    console.log(x);
}
f({a:0});
//Prints
//{a:0}
//0

I would like to deconstruct the object inside the function parameters while also passing the object to the function so that the object can be modified.

3 Answers
Related