Js The Weird Parts Jun 2026

: this refers to the object the method belongs to.

The this keyword is like a chameleon on caffeine. Its value depends entirely on how a function is called. js the weird parts

Ultimately, the "weird parts" of JavaScript are not barriers; they are the fingerprint of the language’s history. They represent the evolution of the web from static pages to complex applications. While the language has its warts—nuances that can turn a simple addition into a string concatenation or a boolean check into a headache—it remains the essential tool of the web. Understanding why NaN === NaN is false, or why typeof null returns "object" , transforms a developer from a code typist into a language mechanic. In the end, the weirdness isn't a bug to be fixed, but a reality to be understood. : this refers to the object the method belongs to

const arr = [1, 2, 3]; arr["foo"] = "bar"; console.log(arr); // [1, 2, 3, foo: "bar"] console.log(arr.length); // 3 (still!) Ultimately, the "weird parts" of JavaScript are not

The keyword this changes its meaning based on how a function is called, not where it is written. : this refers to the window (in browsers).

However, calling these traits "weird" is somewhat of a misnomer; they are simply the consequences of design decisions made for a specific context. JavaScript was designed for the web, a chaotic environment where scripts from different sources had to run together without crashing the browser. The language was built to be forgiving rather than strict. It assumes the developer made a mistake and tries to fix it—converting a string to a number, or allowing access to a hoisted variable—rather than throwing an error. As the language has matured with the introduction of ES6 (ECMAScript 2015), many of these pain points have been addressed. Features like let and const provide block scoping, and arrow functions solve the this binding issue.

JavaScript is "weakly typed," meaning it tries to be helpful by automatically converting data types (coercion) to make an operation work. This leads to classic "weird parts" examples: