I wanted to play around with composition in JS, eg:
Problem: in composition there is used a special arrow syntax with brackets, see (2) in code.
I have an idea how to use it in context of composition.
But I don’t really understand what the bracket are doing. What is the exact functionality of () in arrow notation?
// (1) normal arrow function
const goo = () => console.log(12);
goo(); // 12
// (2) special syntax with extra brackets ???
const moo = () => ({do:()=>console.log(34)});
console.log(moo); // () => ({do:()=>console.log(34)})
// moo() gives me an object:
console.log(moo()); // Object { do: () => console.log(34) }
// I can call do() on that object
moo().do(); // 34