The Weird Side of JavaScript Explained - ...

The Weird Side of JavaScript Explained - Part 2

Jan 29, 2024

1. Arrays Are Not Equal

Despite having identical elements, two distinct arrays are not considered equal in "https://cdn.buymeacoffee.com/uploads/project_updates/2024/01/2903c2c4009ad1d63bda3f5f5e1a529b.png" alt="" title="">The reason is the same as above: == and === compare object references for arrays, and these two arrays are different objects in memory.

2. NaN Is a Number

NaN, which stands for "Not a Number," is ironically classified as a number:

NaN is a special numeric value that indicates that a result cannot be represented as a number. It’s the only value in JavaScript that is not equal to itself.

3. Arrays and Objects

When you try to add arrays or objects, you can get some strange results due to type coercion:The plus operator triggers the default conversion to strings for both arrays and objects, leading to these odd outcomes.

4. Boolean Maths

Even booleans aren't safe from JavaScript’s quirks:In arithmetic operations, true is converted to 1 and false to 0. Therefore, `

Part 1: https://www.buymeacoffee.com/codecrumbs/the-weird-side-javascript-explained-part-1

Original post: https://www.instagram.com/p/C1KUenOsCU9/?utm_source=ig_web_copy_link&igsh=MzRlODBiNWFlZA==

Enjoy this post?

Buy Codecrumbs a coffee

More from Codecrumbs