Here is the code I am confused about:
const getMousePosition = (x, y) => ({
x: x,
y: y
});
I understand the arrow functions. For example,
const addOne = (x) => x + 1;
is the same as
const addOne = function(x) {
return x + 1;
}
What I'm uncertain about is the parenthesis that surround the brackets in the top most code.
...({
x: x,
y: y
});
If they weren't there then the top most code would just return an object... Can someone explain to me what adding the parenthesis will do?
Thanks in advance.