Skip to content
Exit presentation

Programming Proper I

Four kinds of value, and why the quotes matter

12 is a number. "12" looks the same but is not. Quote marks make it text.

Loading lab…

Four kinds, one value each: 12, "12", true, null.
Step 1 of 3
  1. Four kinds, one value each: 12, "12", true, null.
  2. 12 and "12" look alike on the page.
  3. They are two different kinds.

The rule

The kind of a value is what the machine holds. It is not how the writing looks. Run it and ask: number, text, true or false, or nothing?

The four kinds of value, and one of each
The kindWritten down
number12
text"12"
true or falsetrue
nothingnull

4.5 is a number too. Whole numbers and numbers with a decimal point are one kind here. The sign / divides, so 12 / 8 gives 1.5.

Quotes change the answer. 12 + 8 adds two numbers and gives 20. "12" + 8 joins the two as text and gives "128".

0 is a number. "" is text with no characters. false is a true or false value, not nothing. In this editor, only null means no value at all.

print writes something out. It gives back nothing.

Jump to lesson

This track

  1. 0 Start here
  2. 1 The same program, typed instead of dragged
  3. 2 A box you can change, and a box you cannot
  4. 3 Four kinds of value, and why the quotes matter
  5. 4 What the signs do, and the one that does two jobs
  6. 5 A fork in the line
  7. 6 A loop that runs until something stops it
  8. 7 Once for each thing you have
  9. 8 What the message says, and what it does not
  10. 9 The big picture
  11. 10 Track quiz

Other tracks