Truthy & Falsy Values
What will this code output? console.log(Boolean({}));
The code will output true. An empty object ({}) is truthy in JavaScript, so Boolean({}) returns true. All objects in JavaScript, regardless of their contents, are truthy values. This includes all objects created with object literals, constructors, or Object.create(), as well as arrays, functions, dates, regular expressions, and all other object types. This behavior is consistent across all JavaScript environments and is an important aspect of how conditional logic works in the language. When checking if a variable is an object, a simple if(obj) won't tell you if obj is specifically an object—it only confirms it's not one of the six falsy values.