Loading...
Loading...
When to use arrow functions vs function declarations. Follow when writing JavaScript or TypeScript functions.
npx skill4agent add loxosceles/ai-dev javascript-function-stylefunction.map().filter().reduce()this// ✅ Regular functions
function calculateTotal(items: Item[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}
function UserProfile({ userId }: Props) {
return <div>{userId}</div>;
}
// ✅ Arrow functions in appropriate contexts
const numbers = [1, 2, 3].map(n => n * 2);
const handleClick = () => {
console.log('clicked');
};
<Button onClick={() => handleSubmit()} />