Intro to Types

A value type is a computers way of representing a piece of information. Most of them you'll recognise instantly, but there's a few that are created just for computers.

It's really useful to know these terms as we refer to them a lot elsewhere! Each of the examples below (in the grey boxes) are displayed in a format called JSON.

String

A string is a portion of text. You can recognise strings as they're wrapped in speech marks - kind of like the computer is talking to you. They can contain any combination of letters, numbers or emoji - and as long as they're inside the "speech marks" then they belong to that string.

"Mary had 2 donuts for breakfast 🍩🍩"

Number

Represents an amount or quantity. These look exactly as you would expect. They can also have numbers after the decimal place! Don't include commas (e.g.10,000) as a computer won't understand that!

22
334.123112

Boolean

This is simply a true or false value. It's like a yes or no question - there are only two answers.

true
false

Date

A date represents a moment in time - and includes a date (03/10/2019), time (7.01pm and 3 seconds) and a number of milliseconds (102) - computers like to be very precise!

We actually store dates as a number (the number of milliseconds from 01-01-1970). The date 2019-10-03 would be stored as:

1570057200000

Hash

A hash is like a record in a database or a row in Excel. It's a combination of key/value pairs - that just means you have a property (e.g. name) that has some associated value (e.g. 'Calum'). The value can be any of the above, or even another hash. Hashes are great when you want to group related values together - e.g. to represent a customer, order or product.

{ name: 'Calum', age: 27, address: { zipcode: "10001" } }

Array

An array is a list of values (a list value can be any of the above).

Here's a simple array of numbers:

[1, 2, 3, 4, 5]

And here's an array with all different value types:

[1, true, "String", { name: "Calum" }]

Table

A table is an array of hashes. It's like an Excel sheet or table in database. It stores groups of related records together. For example, you may have a table of customers, orders or products. Often tables have a unique key (e.g. id) - this is a value that is unique for each record in the table, and because it's unique it makes looking up a specific record really fast and easy.

[{ id: 1, name: "Calum" }, { id: 2, name: "Jane" }]

That's it - you're now a value type pro 🙌.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.