Guess the console.log output: 15 levels predicting coercion, scope and operator results. A quick-quiz JavaScript fundamentals game for developers.
The typeof operator is used to check a value's data type in JavaScript. The result is always a string like "number", "string", "boolean", etc.
The + operator, when used with strings, joins those strings together. A space isn't added automatically: you have to add it yourself.
Type coercion happens when JavaScript automatically changes a data type. If the + operator meets one string, all operands are turned into strings and joined.
JavaScript has two comparison operators: == (loose equality) does type coercion, while === (strict equality) doesn't. With ==, "1" and 1 are considered equal.
In JavaScript, some values are considered "falsy" (they evaluate to false): false, 0, "", null, undefined, NaN. All other values are "truthy".
A template literal uses backticks (`) and can insert JavaScript expressions inside ${...}. Easier than ordinary concatenation.
And more, 22 levels in all.