# Primitive types

In JavaScript, there are six primitive data types: `boolean`, `number`, `string`, `symbol` (new as of ES6), as well as `null` and `undefined`. TypeScript includes all of these as built-in types.

## Boolean

Booleans have two logical values: `true` or `false`.

```typescript
let isReady: boolean = false;
isReady = 'yes'; // Error: a string is not assignable to type 'boolean'
isReady = true; // OK
```

## Number

All numbers in TypeScript are stored no differently than in JavaScript — as [IEEE 754](http://steve.hollasch.net/cgindex/coding/ieeefloat.html) double-precision floating-point numbers.

```typescript
const integer: number = 6;
const float: number = 6.66;

// Non-decimal numbers are cool too:
const hex: number = 0xf00d;
const binary: number = 0b1010;
const octal: number = 0o744;

// Let's not forget our weird friends:
const negativeZero: number = -0;
const actuallyNumber: number = NaN;
const largeNumber: number = Number.MAX_VALUE;
const pi: number = Math.PI;
const largestNumber: number = Infinity;
```

## String

Strings work the same way as in JavaScript, where both `'` and `"` work correctly, as well as `` ` `` for template literals.

```typescript
const name: string = 'Christine';
const nameTagLabel: string = `Hello, my name is ${name}.`;
```

## Symbol

Symbol is a unique and immutable data type introduced in ES6.

```typescript
let country: symbol = Symbol('Canada'); // OK
country: symbol = 'Canada'; // Error: a string is not assignable to type 'symbol'
// typeof country === "symbol"
```

## Null and Undefined

Both `undefined` and `null` have their own types named `undefined` and `null`, respectively.

```typescript
// Not much else we can assign to these variables!
let u: undefined = undefined;
let n: null = null;

// To illustrate:
u = 200; // Error: a number is not assignable to type 'undefined'
n = 'idk'; // Error: a string is not assignable to type 'null'
```

By default `null` and `undefined` are subtypes of all other types, which means you can assign `null` and `undefined` to something having another type. For example:

```typescript
let myNum: number = 500;
myNum = null; // OK
myNum = undefined; // also OK
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shopify-1.gitbook.io/typescript/beginner/basic-types/primitive-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
