Saltar al contenido
Skillpedia
Sitios e interfaces (frontend)75 mil · #2781

const-let

Qué hace

Esta skill comprueba que el JavaScript no use declaraciones var y sugiere const o let en su lugar. Es para desarrolladores que quieren código más seguro y fácil de leer.

Cuándo usarla

  • ✓Cuando encuentras var en un archivo JavaScript antiguo.
  • ✓Cuando una variable parece accesible donde no debería.
  • ✓Cuando revisas código en busca de claridad antes de una publicación.

Link de la skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/const-let/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/const-let/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

“Revisa este script y sustituye cada var por const o let.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Tu agente enumera cada declaración var con su número de línea y luego usa const para los valores que nunca cambian y let para los que se reasignan.

Contenido técnico (SKILL.md original)

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

Prefer const and let over var

var's function scope and hoisting behavior regularly causes bugs where variables are accessible outside the block they were declared in. const and let enforce block scope and make code intent clearer — const signals that a binding should not be reassigned, which helps readers understand data flow.

Quick Reference

  • Use const for values that are never reassigned
  • Use let when reassignment is needed
  • Never use var — it has function scope and is hoisted, causing subtle bugs
  • const does not mean immutable — objects and arrays declared with const can still be mutated

Check

Scan this JavaScript file for any use of var and flag every occurrence with line numbers.

Fix

Replace all var declarations with const or let as appropriate. Use const when the variable is never reassigned, let otherwise.

Explain

Explain why const and let are preferred over var, covering scope, hoisting, and temporal dead zone.

Code Review

Review scripts, client components, and browser execution paths related to Prefer const and let over var. 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/const-let

Preguntas frecuentes

¿Por qué var es arriesgado?

La skill indica que var tiene alcance de función y elevación, lo que puede causar errores sutiles.

¿Cuándo debo usar const?

Cuando la variable nunca se reasigna.

¿const hace que los objetos no puedan cambiar?

No. La skill aclara que los objetos y arrays declarados con const sí pueden modificarse.

Detalles

Descripción original del autor

Use when reviewing scripts, client components, bundles, or runtime behavior related to Prefer const and let over var. 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
#2781
Licencia
MIT
Actualizada
31/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas