Values & types - Coding concepts using Sheets

I'm writing a series of posts to explain basic coding concepts using Google Sheets. In this post, I will explain what a value is and I will also introduce the concept of a data type.

Values are the data used by a computer program

A spreadsheet is very similar to a computer program in that you have input data that you analyze or process (usually via formulas) to generate some output data.

Consider a spreadsheet containing the names, birthdays and test scores of 3 students. These would be the input data or input values. When you use the AVERAGE() function to calculate the average test score, you're generating an output value using your "spreadsheet program".

Values have types

In Google Sheets, every value has a type. Some of the common types are:

  • Numbers
  • Text
  • Boolean (true or false)

In many programming languages, these types are also known as "data types". The number of supported types can vary from one programming language to another but the concept (of a data type) itself can be found in most programming languages.

You can use the TYPE() function to find out the type of a value. This function returns

  • 1 if the value is a number
  • 2 if the value is text
  • 4 if the value is boolean
Value
Type of value
=TYPE()
Notes
100
Numeric
1
John Ramsey
Text
2
10/9/2015
Numeric
1
Dates are numeric values under the hood.
TRUE
Boolean
4

Most programming languages have some way to find out the type of a value. For example, in Apps Script, you can find out the type of a value using the typeof operator.

Logger.log(typeof 2);

Have feedback for me?

I'd appreciate any feedback you can give me regarding this post.

Was it useful? Are there any errors or was something confusing? Would you like me to write a post about a related topic? Any other feedback is also welcome. Thank you so much!