I would like to know if the following is possible with ES6.
I have an object "o" with method:
get(name) {
}
Which returns some other object depending on the provided name.
I have another function test like this:
function test(o) {
}
I wonder is there any way to destructur the paramaters with calliing get on the object.
For example: This is not working - it's the thing i want to do
// here is what I'm trying to do
function test({db: get('db')}) {
}
// this is working
function test(o) {
var db = o.get('db');
}
I want "db" varaible to equal "o.get('db')". I can do it in the function body but I wonder if it's possible to make the it direclty in the argument definition.
So far I can use:
let [a, b, c] = [o.get('a'), o.get('b'), o.get('c')];
As first line in the function.
Thanks
get.Function#bind?