Back to skills
SKILL.md
Js Early Exit
ASecurityImported skill js_early_exit from vercel
- 3 stars
- 0 votes
- 0 copies
- 2 views
- Added September 11, 2026
Security analysis
100/100npx -y skills add bitwikiorg/skills.md --skill js_early_exit --agent claude-codeAre you the author of Js Early Exit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/bitwikiorg-js-early-exit)---
description: Imported skill js_early_exit from vercel
name: js_early_exit
signature: 925ce5ce87f3347186ca62212f29cc6baa2b8c85a96d2720ad07c3d0abf781c0
source: /a0/tmp/skills_research/vercel/skills/react-best-practices/rules/js-early-exit.md
---
---
title: Early Return from Functions
impact: LOW-MEDIUM
impactDescription: avoids unnecessary computation
tags: javascript, functions, optimization, early-return
---
## Early Return from Functions
Return early when result is determined to skip unnecessary processing.
**Incorrect (processes all items even after finding answer):**
```typescript
function validateUsers(users: User[]) {
let hasError = false
let errorMessage = ''
for (const user of users) {
if (!user.email) {
hasError = true
errorMessage = 'Email required'
}
if (!user.name) {
hasError = true
errorMessage = 'Name required'
}
// Continues checking all users even after error found
}
return hasError ? { valid: false, error: errorMessage } : { valid: true }
}
```
**Correct (returns immediately on first error):**
```typescript
function validateUsers(users: User[]) {
for (const user of users) {
if (!user.email) {
return { valid: false, error: 'Email required' }
}
if (!user.name) {
return { valid: false, error: 'Name required' }
}
}
return { valid: true }
}
```
Attribution
Comments
Loading comments…