Notes
Short notes from what I'm learning and building - one thought, one topic, a few minutes to read.
-
typeof vs instanceof - two ways to check a type in JS
JavaScript has two core operators for checking what type a value is, and each answers a different question.
typeofreturns one of 8 strings and has known gotchas (null, arrays).instanceofwalks the prototype chain and fails for objects from an embedded<iframe>. A note on when to use which, and why arrays have a dedicatedArray.isArray. -
Property descriptors and getters/setters in JavaScript
Every object property in JS carries 4 flags under the hood (writable, enumerable, configurable, plus value or get/set). You rarely think about them - until something odd happens: an assignment doesn't change the value,
deletedoesn't remove the field,for...inskips the property. A note on what property descriptors are, how getters/setters work, and whyObject.definePropertyhas different defaults than an object literal. -
Number quirks in JavaScript
JavaScript has a single numeric type -
number- and plenty of things that trip up on it. A note on IEEE 754,NaN, precision limits, andBigInt. Why0.1 + 0.2 !== 0.3and whyNaN === NaNis false. -
How call, apply, and bind work in JavaScript
Three methods on
Function.prototypewith the same goal - settingthis. The differences are in (a) whether they invoke immediately, and (b) how you pass arguments. A quick rundown of which to use when. -
How the prototype chain works in JavaScript
In JavaScript an object can call a method it doesn't own. Class methods are defined once, on a shared prototype, and instances reach for them through a link. The mechanism is called the prototype chain. A note on how it works and why.
-
How == differs from === in JavaScript
The classic explanation says
==checks values and===checks both type and value. The spec says something different - both check the type. This note is about what the actual difference is. -
When to use let, when var in JavaScript
The common advice says: always
let, nevervar. But each of them communicates something different about the author's intent. A note on whenvarstill makes sense and how to choose between them. -
What const protects in JavaScript
A common saying is that
constmeans „immutable". In reality it only protects assignment to the name, not the value itself - that's why mutating an array declared withconstworks, but trying to assign it something new throws.