HTML Academy
Data types
Introduction to programming5/15
Back to the list of tasks
  • 1. Career start
  • 2. Making the program a bit more complicated
  • 3. Console log
  • 4. Data types
  • 5. Complex data types
  • 6. Unknown data
  • 7. Variables
  • 8. Declaring and assigning variables
  • 9. Operations
  • 10. Operations order
  • 11. A few more operations
  • 12. Release of Brekkie-meter v0.1, part 1
  • 13. Release of Brekkie-meter v0.1, part 2
  • 14. Summary of “Getting to know JavaScript”
  • 15. First program: MufFit v0.1
Unknown data
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Complex data types

On the previous step, you learned about three data types:

  • number for numbers,
  • string for strings,
  • boolean for logical or boolean values, true or false.

In reality, you learned about four data types. Special data type undefined contains just one value undefined.

By the way, the number type in JavaScript is intended for integers and non-integer numbers. In other languages, such numbers require different data types.

Let’s now take a look at more complex or compound data types: array and object.

Compound types contain more than one value. The array array stores the sequence of values ​, ​and the order of these values ​​is important. The object object consists of a multitude of “key-value” pairs, and the order of these pairs is not important. These types of data are recorded as follows:

// Array
[1, 2, 3, 4, 5]

// Object
{month: 'june', day: 15}

// Logs array in the console
console.log([1, 2, 3, 4, 5]);

// Logs array in the console
console.log({month: 'june', day: 15});

We will analyze each of these types of data later, in the courses that are still to come.

Comments

  • script.js
JavaScript

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

Console

The code has changed, click “Run” or turn autorun on.

Result

Goalscompleted

Use the console.log() command to output the values below to the console and check their types. For each value, enter a command with a new line:

  1. [50, 320, 480]
  2. {meal: 'Breakfast', energy: 50}

Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

VISAMastercard

Log in

or

Forgot your password?

Sign up

Sign up

or
Log in

Restore access

Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

Forgot to connect your email to the profile? Email us and we’ll help.