Files
kolaytercih/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md
bilalgursen ea85a053c5
All checks were successful
Deploy / deploy (push) Successful in 7m30s
feat: add new skills to skills-lock.json and update use-pixel-heat component
- Added new skills: find-skills, frontend-ui-engineering, and vercel-react-best-practices to skills-lock.json.
- Updated use-pixel-heat.ts to import both animate and AnimationPlaybackControls from motion for improved animation handling.
2026-08-08 16:08:54 +03:00

25 lines
532 B
Markdown

---
title: Use Set/Map for O(1) Lookups
impact: LOW-MEDIUM
impactDescription: O(n) to O(1)
tags: javascript, set, map, data-structures, performance
---
## Use Set/Map for O(1) Lookups
Convert arrays to Set/Map for repeated membership checks.
**Incorrect (O(n) per check):**
```typescript
const allowedIds = ['a', 'b', 'c', ...]
items.filter(item => allowedIds.includes(item.id))
```
**Correct (O(1) per check):**
```typescript
const allowedIds = new Set(['a', 'b', 'c', ...])
items.filter(item => allowedIds.has(item.id))
```