There are two main ways to write functions in JavaScript:
function foo() { … } (regular function declarations/expressions)const foo = () => { … } (arrow functions)We want to pick one default style for our codebase and enforce it.
Our codebase:
this, no new, no prototypes)If you write a function in our codebase, write it as an arrow function.
✅ Allowed:
const sum = (a, b) => a + b;
const doubleAll = (xs) => xs.map(x => x * 2);
❌ Not allowed (without a specific reason):
function sum(a, b) {
return a + b;
}
[1, 2, 3].map(function (x) {
return x * 2;
});
We also use rest parameters instead of arguments:
const logAll = (...args) => {
console.log(args);
};
Note: Regular functions allowed for library/framework requirements, constructors, or generators where arrow functions aren't supported.
We don't use classes, this, or OOP patterns, so most traditional differences between regular and arrow functions don't matter for us. What's left are readability, consistency, and a few minor language features:
| Aspect | Regular Functions | Arrow Functions | Our Take |
|---|---|---|---|
| this / OOP | Own dynamic this, used in classes/objects |
Lexically inherits this |
We avoid this and OOP; not needed |
| arguments | Has arguments (array-like) |
No own arguments |
We prefer ...args everywhere |
| Constructors / new | Can be used with new, has prototype |
Cannot be used with new |
We don't design with constructors |
| Hoisting | Declarations are hoisted | Expressions are not hoisted | We are fine defining before use |
| Readability / style | More verbose, mixed styles possible | Short, uniform, matches FP style | Clearer, more concise |
| Performance (our usage) | Optimized by engines | Optimized by engines | No meaningful difference |
this-heavy code)