Saltar al contenido
Skillpedia
Programación general75 mil · #3066

type-coercion

Qué hace

Esta skill revisa código JavaScript en busca de comparaciones y conversiones que pueden dar resultados sorprendentes. Es para desarrolladores que quieren menos errores ocultos.

Cuándo usarla

  • ✓Cuando el código JavaScript usa == o != en lugar de comparaciones estrictas.
  • ✓Cuando se suman valores de forma que se mezclan texto y números.
  • ✓Cuando una revisión de código pide un manejo de tipos más claro en un script.

Link de la skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-coercion/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-coercion/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Mi JavaScript a veces compara valores mal. ¿Puedes encontrar las comparaciones flexibles y volverlas estrictas?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente encuentra las comprobaciones de igualdad flexibles y las operaciones arriesgadas entre tipos distintos. Las sustituye por comparaciones estrictas y conversiones explícitas.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Avoid implicit type coercion

JavaScript's implicit type coercion produces results that look like bugs to anyone who doesn't know the exact coercion rules. == comparisons with mixed types silently convert values in ways that fail to catch genuine errors. Explicit conversions make code intent clear and catch real type mismatches at the point where they occur.

Quick Reference

  • Always use === and !== instead of == and !=
  • Convert types explicitly with Number(), String(), Boolean(), parseInt()
  • Be careful with + operator — it concatenates strings but adds numbers
  • Use Array.isArray() instead of typeof for array checks

Check

Find all uses of == and != (non-strict equality) in this file. Also look for implicit type conversions from + operator and other coercion traps.

Fix

Replace all == with === and != with !==. Add explicit type conversions where mixed types are intentionally compared.

Explain

Explain JavaScript's implicit type coercion rules, why == is problematic, and how to write safe type comparisons.

Code Review

Review scripts, client components, and browser execution paths related to Avoid implicit type coercion. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/type-coercion

Preguntas frecuentes

¿Por qué es un problema ==?

Convierte los valores automáticamente antes de compararlos, lo que puede ocultar errores reales y hacer que los resultados sean difíciles de predecir.

¿Cuál es la forma más segura de comprobar arrays?

La skill recomienda Array.isArray() en lugar de typeof para comprobar arrays.

¿Cómo deben convertirse los tipos?

Usando funciones explícitas como Number(), String(), Boolean() o parseInt().

Detalles

Descripción original del autor

Use when reviewing scripts, client components, bundles, or runtime behavior related to Avoid implicit type coercion. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.

repo: thedaviddias/Front-End-Checklist

Popularidad

Estrellas en GitHub
75 mil
Posición en el ranking
#3066
Licencia
MIT
Actualizada
31/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas