मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग75k · #3066

type-coercion

यह क्या करती है

यह स्किल JavaScript कोड में ऐसी तुलनाएँ और रूपांतरण देखती है जो चौंकाने वाले नतीजे दे सकते हैं। यह उन डेवलपर्स के लिए है जो छिपे बग कम करना चाहते हैं।

कब इस्तेमाल करें

  • ✓जब JavaScript कोड में सख़्त तुलना की जगह == या != इस्तेमाल हो।
  • ✓जब टेक्स्ट और संख्याओं को ऐसे तरीके से जोड़ा जाए जो आपस में मिल जाएँ।
  • ✓जब कोड समीक्षा में किसी स्क्रिप्ट में type संभालने का साफ़ तरीका माँगा गया हो।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/type-coercion/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरा JavaScript कभी-कभी मानों की गलत तुलना करता है। क्या आप ढीली तुलनाएँ खोजकर उन्हें सख़्त बना सकते हैं?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट ढीली बराबरी वाली जाँच और जोखिम भरे मिश्रित-type ऑपरेशन खोजता है। उन्हें वह सख़्त तुलना और साफ़ रूपांतरण से बदलता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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

अक्सर पूछे जाने वाले सवाल

== क्यों समस्या है?

तुलना से पहले यह मानों को अपने-आप बदल देता है, जिससे असली गलतियाँ छिप सकती हैं और नतीजे अनुमान से बाहर हो सकते हैं।

arrays की जाँच का सुरक्षित तरीका क्या है?

स्किल arrays जाँचने के लिए typeof की जगह Array.isArray() सुझाती है।

type कैसे बदलने चाहिए?

Number(), String(), Boolean() या parseInt() जैसे साफ़ फ़ंक्शन इस्तेमाल करें।

जानकारी

लेखक का मूल विवरण

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

लोकप्रियता

GitHub स्टार
75k
रैंकिंग में स्थान
#3066
लाइसेंस
MIT
अपडेट की गई
31/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills