# JavaScript Literals

JavaScript mein **literal** ka simple matlab hota hai:  
koi bhi value jo aap directly code mein likhte ho (without calculation or variable reference)

```javascript
let x = 42;        // 42 is a numeric literal
let name = "Raj";  // "Raj" is a string literal
```

Rule:

*   Direct value = literal
    
*   No computation
    
*   No function needed
    

Types of JavaScript Literals

1\. Numeric Literals

Numbers ko different formats mein likh sakte ho:

```javascript
let int = 25;
let float = 99.99;

let hex = 0xFF;     // 255
let binary = 0b1010; // 10
let octal = 0o17;    // 15
```

2\. String Literals

```javascript
let a = 'Hello';
let b = "World";
let c = `Hello World`;
```

Template Literals (Modern Way)

```javascript
let name = "Amit";
console.log(`Hello ${name}`);
```

Features:

*   Variable embedding (`${}`)
    
*   Expressions allowed
    
*   Multi-line support
    

3\. Boolean Literals

```javascript
let isOnline = true;
let isAdmin = false;
```

Only two values:

*   `true`
    
*   `false`
    

4\. Array Literals

```javascript
let fruits = ["apple", "banana", "mango"];
let numbers = [1, 2, 3, 4];
let mixed = [1, "hello", true];
```

Index starts from `0`

```javascript
console.log(fruits[0]); // apple
```

5\. Object Literals

```javascript
let student = {
  name: "Rahul",
  age: 21,
  city: "Delhi"
};
```

Access::

```javascript
console.log(student.name);
```

6\. Special Literals

```javascript
let a = null;       // intentional empty value
let b = undefined;  // value not assigned
```

| Type | Meaning |
| --- | --- |
| null | intentionally empty |
| undefined | not assigned yet |

Quick Summary
