Master JavaScript objects and arrays including manipulation methods, prototypal inheritance, and complex data structure patterns.
Provides JavaScript object and array manipulation methods, destructuring, and immutable update patterns. Claude uses this when you need to transform data structures, access nested properties safely, or implement common patterns like grouping, indexing, or filtering.
/plugin marketplace add pluginagentmarketplace/custom-plugin-javascript/plugin install javascript-developer-plugin@pluginagentmarketplace-javascriptThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/array-methods.yamlassets/config.yamlreferences/COLLECTIONS-GUIDE.mdreferences/GUIDE.mdscripts/benchmark-data-structures.jsscripts/helper.py// Create
const obj = { name: 'Alice', age: 30 };
// Access
obj.name; // Dot notation
obj['name']; // Bracket notation
obj?.address?.city; // Optional chaining
// Modify
obj.email = 'a@b.com'; // Add/update
delete obj.age; // Remove
const { name, ...rest } = obj; // Destructure
Object.keys(obj); // ['name', 'age']
Object.values(obj); // ['Alice', 30]
Object.entries(obj); // [['name','Alice'], ['age',30]]
Object.fromEntries(entries); // Reverse
Object.assign({}, a, b); // Shallow merge
{ ...a, ...b }; // Spread merge (preferred)
Object.freeze(obj); // Immutable
Object.seal(obj); // No add/delete
Transform (new array)
arr.map(x => x * 2); // Transform each
arr.filter(x => x > 0); // Keep matches
arr.slice(1, 3); // Extract portion
arr.flat(2); // Flatten nested
arr.flatMap(x => [x, x*2]); // Map + flatten
Search
arr.find(x => x > 5); // First match
arr.findIndex(x => x > 5); // First index
arr.findLast(x => x > 5); // Last match (ES2023)
arr.includes(5); // Boolean check
arr.indexOf(5); // Index or -1
Reduce
arr.reduce((acc, x) => acc + x, 0); // Sum
arr.reduce((acc, x) => ({ ...acc, [x.id]: x }), {}); // Index by
Check
arr.every(x => x > 0); // All pass
arr.some(x => x > 0); // Any pass
Mutate (modify original)
arr.push(x); // Add end
arr.pop(); // Remove end
arr.unshift(x); // Add start
arr.shift(); // Remove start
arr.splice(i, n, ...items); // Remove/insert
arr.sort((a,b) => a - b); // Sort
arr.reverse(); // Reverse
// Object
const { name, age = 0 } = user;
const { name: userName } = user; // Rename
const { address: { city } } = user; // Nested
// Array
const [first, , third] = arr; // Skip
const [head, ...tail] = arr; // Rest
[a, b] = [b, a]; // Swap
// Group by
const byRole = users.reduce((acc, u) => {
(acc[u.role] ??= []).push(u);
return acc;
}, {});
// Unique values
const unique = [...new Set(arr)];
// Index by ID
const byId = arr.reduce((acc, x) => ({ ...acc, [x.id]: x }), {});
| Problem | Symptom | Fix |
|---|---|---|
| Shallow copy bug | Nested changes shared | Use structuredClone() |
| Mutation side effect | Original changed | Use spread/map |
undefined access | Property doesn't exist | Use ?. optional chain |
| Sort not working | Wrong order | Provide compare function |
// Modern (preferred)
const deep = structuredClone(original);
// JSON (limited - no functions, dates)
const deep = JSON.parse(JSON.stringify(original));
// 1. Inspect structure
console.log(JSON.stringify(obj, null, 2));
// 2. Check array vs object
console.log(Array.isArray(value));
// 3. Check prototype
console.log(Object.getPrototypeOf(obj));
// Object
const updated = { ...user, name: 'New Name' };
// Array
const added = [...arr, newItem];
const removed = arr.filter(x => x.id !== id);
const updated = arr.map(x => x.id === id ? { ...x, ...changes } : x);
const city = user?.address?.city ?? 'Unknown';
const first = arr?.[0] ?? defaultValue;
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.