type-coercion
What it does
This skill reviews JavaScript code for comparisons and conversions that can give surprising results. It is for developers who want fewer hidden bugs.
When to use it
- ✓When JavaScript code uses == or != instead of strict comparisons.
- ✓When values are added together in a way that mixes text and numbers.
- ✓When a code review asks for clearer type handling in a script.
Skill link
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-coercion/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“My JavaScript sometimes compares values wrongly. Can you find the loose comparisons and make them strict?”
5 new skills a week. 1 minute to read.
How it works
The agent finds loose equality checks and risky mixed-type operations. It replaces them with strict comparisons and explicit conversions.
Technical content (original SKILL.md)
Original text by the author, straight from 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
FAQ
Why is == a problem?
It converts values automatically before comparing them, which can hide real mistakes and make results hard to predict.
What is the safer way to check for arrays?
The skill recommends Array.isArray() instead of typeof for checking arrays.
How should types be converted?
Use explicit functions such as Number(), String(), Boolean() or parseInt().
Details
Original description by the author
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.
Popularity
- GitHub stars
- 75k
- Ranking position
- #3066
- License
- MIT
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
frontendchecklist
75kChecks frontend code and live pages against 380+ rules for accessibility, speed, SEO and security, using a command-line tool.
frontend-checklist-global
75kAudits a frontend project against all 386 Front-End Checklist rules, and gives a specific fix for each issue found.
404-page
75kChecks that your missing-page screen offers helpful links and returns a real 404 status, to help lost visitors find their way.
about-page
75kReviews whether your site has a clear About page that explains who runs it, to build trust with visitors and search engines.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.