Title: JavaScript Type Coercion — Why '149.99' + Tax Broke It
Open Graph Title: JavaScript Type Coercion — Why '149.99' + Tax Broke It
Description: String '149.99' + 0.08 tax = '149.990.08' broke a real checkout flow. typeof null returns 'object'. Fix type coercion bugs before they cost you.
Open Graph Description: String '149.99' + 0.08 tax = '149.990.08' broke a real checkout flow. typeof null returns 'object'. Fix type coercion bugs before they cost you.
Opengraph URL: https://thecodeforge.io/javascript/data-types-javascript/
Domain: thecodeforge.io
{
"@context": "https://schema.org",
"@type": "TechArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://thecodeforge.io/javascript/data-types-javascript/"
},
"headline": "JavaScript Type Coercion — Why '149.99' + Tax Broke It",
"description": "String '149.99' + 0.08 tax = '149.990.08' broke a real checkout flow. typeof null returns 'object'. Fix type coercion bugs before they cost you.",
"keywords": "JavaScript Type Coercion — Why '149.99' + Tax Broke It, JavaScript, Beginner, JS Basics, String '149.99' + 0.08 tax = '149.990.08' broke a real checkout flow. typeof null returns 'object'. Fix type coercion bugs before they cost you.",
"proficiencyLevel": "Beginner",
"author": {
"@type": "Person",
"@id": "https://thecodeforge.io/about/#naren",
"name": "Naren",
"url": "https://thecodeforge.io/about/"
},
"publisher": {
"@type": "Organization",
"@id": "https://thecodeforge.io/#org",
"name": "TheCodeForge",
"url": "https://thecodeforge.io",
"logo": {"@type": "ImageObject", "url": "https://thecodeforge.io/assets/og-image.png"}
},
"datePublished": "2026-03-17T00:00:00+00:00",
"dateModified": "2026-11-03T00:00:00+00:00",
"url": "https://thecodeforge.io/javascript/data-types-javascript/",
"inLanguage": "en",
"educationalLevel": "Beginner",
"image": "https://thecodeforge.io/assets/og-image.png",
"isPartOf": {"@id": "https://thecodeforge.io/#website"}
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{"@type": "ListItem", "position": 1, "name": "Home", "item": "https://thecodeforge.io/"},
{"@type": "ListItem", "position": 2, "name": "JavaScript", "item": "https://thecodeforge.io/javascript/"},
{"@type": "ListItem", "position": 3, "name": "JavaScript Type Coercion — Why '149.99' + Tax Broke It", "item": "https://thecodeforge.io/javascript/data-types-javascript/"}
]
}
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Why does typeof null return 'object'?",
"acceptedAnswer": {
"@type": "Answer",
"text": "This is a bug in the original JavaScript implementation from 1995. null was represented internally with a type tag that matched objects. Fixing it would break existing code, so it was never corrected. Always check for null with val === null, not typeof val === 'object'."
}
},
{
"@type": "Question",
"name": "What is the difference between Number and number in JavaScript?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Lowercase number is the primitive type — what you get from literals like 42 or 3.14. Uppercase Number is the wrapper object — rarely used directly. When you call number methods like (42).toFixed(2), JavaScript automatically wraps the primitive in a Number object temporarily. You almost never need to use new Number()."
}
},
{
"@type": "Question",
"name": "When should I use BigInt?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Use BigInt when you need integers larger than Number.MAX_SAFE_INTEGER (2^53 - 1 = 9,007,199,254,740,991). Common cases: database IDs from systems using 64-bit integers, cryptography, precise financial calculations. BigInt and Number cannot be mixed in arithmetic — convert explicitly."
}
},
{
"@type": "Question",
"name": "What is the difference between Symbol and Symbol.for()?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Symbol() creates a new unique symbol every time it's called. Symbol.for(key) creates a symbol that is shared across the entire JavaScript runtime — if you call Symbol.for('foo') in different parts of your app, you get the same symbol. Use Symbol.for() for cross-module constants, Symbol() for private properties."
}
},
{
"@type": "Question",
"name": "How do I check if a value is NaN?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Use Number.isNaN(value). The global isNaN() function coerces the argument to a number before checking, which can give false positives. For example, isNaN('string') returns true (because 'string' coerces to NaN), but Number.isNaN('string') returns false. Always use Number.isNaN() for reliability."
}
}
]
}
| og:type | website |
| og:image | https://thecodeforge.io/assets/og-image.png |
| og:image:width | 1200 |
| og:image:height | 630 |
Links:
Viewport: width=device-width, initial-scale=1.0
Robots: max-image-preview:large