Javascript Weird Parts Jun 2026

'5' + 3 // "53" (Coerced to String) '5' - 3 // 2 (Coerced to Number) Use code with caution.

console.log(NaN == NaN); // false console.log(Number.isNaN(NaN)); // true

obj.printName();

JavaScript is known for its lenient type system, which can sometimes lead to unexpected type coercions.

console.log(x); // undefined var x = 5;

Before your code ever runs, the JavaScript engine performs a "creation phase" where it sets up memory space for variables and functions. This is known as .

console.log(y); // outputs ReferenceError let y = 10; javascript weird parts

You can even generate the word "banana" through extreme coercion. javascript

The delete operator can be used to remove properties from objects, but it has some quirks. '5' + 3 // "53" (Coerced to String)

const obj = { a: { b: { c: 'value' } } };

According to the IEEE 754 floating-point spec (which JS uses), NaN is a numeric data type that represents an invalid number. It’s a number that isn’t a number. The weirdness doesn't stop there: This is known as