> For the complete documentation index, see [llms.txt](https://eleven-fifty-academy.gitbook.io/javascript-101-fundamentals/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eleven-fifty-academy.gitbook.io/javascript-101-fundamentals/1-javascript-fundamentals/1-js-fundamentals/1-grammar-and-types/types.md).

# Types

JavaScript has seven different defined data-types:

1. `boolean`: Binary data-type. Only valid values are true or false.
2. `null`: keyword that denotes a null value. This is not 0. It is the absence of value
3. `undefined`: a data-type that has not been defined with a value.
4. `number`: a numerical data-type.
5. `string`: any combination of characters to be read as text.
6. `symbol`: used to make anonymous object properties.
7. `object`: a container which can hold multiple data-type values.

## Examples of each

### boolean

```javascript
let x = true;
console.log(x); //true
```

### null

```javascript
let x = null;
console.log(x); //null = no value;
```

### undefined

```javascript
let x;
console.log(x); //undefined - no value assigned
```

### number

```javascript
let x = 17;
console.log(x); //17
```

### string

```javascript
let x = 'Hello World!';
console.log(x); //Hello World!
```

### symbol

```javascript
const MY_KEY = Symbol();
const obj = {
    [MY_KEY]: 123
};
```

### Object

```javascript
let x = {
    hello: 'test',
    number: 13
};
console.log(x.hello); //'test'
console.log(x.number); //13
```

## Dynamically-typed

JavaScript is a dynamically-typed language, meaning that variables aren't assigned a specific type. You can see this in action with the following example:

```javascript
let x = 19;
console.log(x); //x
x = 'tree';
console.log(x); //'tree'
x = false;
console.log(x); //false
```

A single variable can be assigned multiple types, but only one type at any given time. Each time a value is assigned, it replaces the previous value.

## File Location

```
    javascript-library
        └── 1-Fundamentals
            └── 1-Grammar-and-Types
                05-types.js <-- You are here
```

## Practice

1. In `types.js`, create a variable for each type and print each to the console.&#x20;
2. Create a new variable. Use the `typeof` keyword to print to the console:`console.log(typeof x)`
3. Change the value of that variable to a different data-type, then use `typeof` again.&#x20;
4. What happens? How can this be utilized in a program?
