> For the complete documentation index, see [llms.txt](https://hemantajax-2.gitbook.io/es6-in-depth/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hemantajax-2.gitbook.io/es6-in-depth/block-scope/const-declaration.md).

# Constant

have block scope like let keyword

```javascript
// ES5
var value = "hey";
value = "Cool";
console.log(value); // Cool

// ES6
const value = "hey";
value = "Cool";
console.log(value); // Error: "value" is read-only
```

## Another Example

```javascript
const obj = {};
obj.name = "Hemant";
console.log(obj); // {name: "Hemant"}

// but
const obj = {};
obj = {location: "HYD"};
console.log(obj); // Error: "obj" is read-only

obj.location = "BLR"; 
console.log(obj.location); // BLR

// If you really want to frreeze
const obj = Object.freeze(obj);
obj.location = "BLR"; 
console.log(obj.location); // still "HYD"
```

## Use Cases

```javascript
const API_KEY = "XXX";
const API_SECRET = "DDGD_DDDGG-SS";
const port = 4000;
const PI =3.14;
```
