Work with numbers and booleans, and read a value's type.

Primitive Types

primitive_types.js
const n = 42;
const big = n > 10;
const kind = typeof n;

console.log("n=" + n);
console.log("big=" + big);
console.log("kind=" + kind);

Follow the Primitives

  1. n starts at 42.
  2. big = n > 10 becomes true.
  3. kind = typeof n becomes number.
  4. The program prints n=42, big=true, and kind=number. | n | big | kind | | --- | --- | --- | | 7 | false | number | | 42 | true | number | | 100 | true | number |
primitive-types Numbers and booleans are primitive values. A comparison yields a boolean, and `typeof` reports the type name as a string.

Exercise: primitive_types.js

Reproduce big=true and kind=number for n=42, then use the pinned n values 7 and 100 to predict big.