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…
Step 1 of 3
- Four kinds, one value each: 12, "12", true, null.
- 12 and "12" look alike on the page.
- 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 kind | Written down |
|---|---|
| number | 12 |
| text | "12" |
| true or false | true |
| nothing | null |
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.