Skip to content
Skillpedia
General coding75k · #3066

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.md

Copy 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

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-coercion/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

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.

repo: thedaviddias/Front-End-Checklist

Popularity

GitHub stars
75k
Ranking position
#3066
License
MIT
Updated
10/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills