DabScript
Essentials

Data Types

Learn about data types in JavaScript.

String

A text of characters enclosed in quotes.

const stringValue = 'Hello, world!';
const stringValue2 = "Hello, world!";

Using single quotes for strings is way more common than using double quotes.

Number

A number representing a mathematical value.

const numberValue = 10;
const numberValue2 = 10000;

Boolean

A data type representing true or false.

const booleanValue = true;
const booleanValue2 = false;

Array

Arrays are ordered lists of values.

const firstArray = [1, 2, 3];
const secondArray = [10, 'a string', { prop: 'value' }, [1, 2, 3]];

The index starts at 0. So we use firstArray[0] to indicate the first value of firstArray.

console.log(firstArray[0]);
console.log(secondArray[3]);
console.log(secondArray[3][0]);

Object

A collection of key-value pairs of data.

const objectVariable = { prop1: 20, prop2: 50 };

console.log(objectVariable);

Objects can be infinitely nested. Unlike arrays, we use the dot notation to access the properties.

const nestedObject = {
  layer1: {
    layer2: {
      layer3: {
        targetValue: 20
      }
    }
  }
};

console.log(nestedObject.layer1.layer2.layer3.targetValue);

We can also retrieve a value from an object by specifying the property.

console.log(objectVariable['prop2']);

© 2026 DabAZ.