Arrow functions have a built in way to shorten a return syntax: If an arrow function is simply returning a single line of code, you can omit the statement brackets and the return keyword. This tells the arrow function to return the statement. So the only thing you need to do is to add the return
keyword explicit if you are not using an arrow function.
const R = function(elem){ return object(document.querySelector(elem)) };
And be careful if you try to translate an arrow function which is using this
keyword.
UPDATE: Response to comment
In the following code there are parenteses used to define an object with a function as property. If you don't use parenteses you need braces and return inside this arrow function, otherwise you get an SyntaxError.
const object = (elem) => ({
css: function(attribute, value) {
elem.style[attribute] = value;
return object(elem);
}
});
Without arrow functions it becomes:
const object = function(elem) {
return {
css: function(attribute, value) {
elem.style[attribute] = value;
return object(elem);
}
};
}