skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
loxosceles-dev/dev-skills135 installs

javascript-function-style

When to use arrow functions vs function declarations. Follow when writing JavaScript or TypeScript functions.

How do I install this agent skill?

npx skills add https://github.com/loxosceles-dev/dev-skills --skill javascript-function-style
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    The skill is a coding style guide for JavaScript and TypeScript functions. No security risks were identified.

  • Socketpass

    No alerts

  • Snykpass

    Risk: LOW · No issues

What does this agent skill do?

JavaScript/TypeScript Function Style

This is a strict guideline. Follow these rules exactly.

How to write functions in JavaScript and TypeScript projects.


Function Declarations vs Arrow Functions

Use function keyword for:

  • Regular function definitions
  • Top-level functions
  • Named functions that need hoisting

Use arrow functions for:

  • Array methods (.map(), .filter(), .reduce())
  • Inline callbacks
  • React component props
  • When you need lexical this binding

Examples

// ✅ 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()} />

Why This Pattern

  • Consistency: Clear rule makes codebase predictable
  • Readability: Function declarations are more explicit
  • Flexibility: Arrow functions where they provide value (conciseness, lexical scope)

Progressive Improvement

If the developer corrects a behavior that this skill should have prevented, suggest a specific amendment to this skill to prevent the same correction in the future.

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/loxosceles-dev/dev-skills/javascript-function-style">View javascript-function-style on skillZs</a>