# Why JavaScript in MakeCode don't accept var?

**URL:** https://forum.makecode.com/t/why-javascript-in-makecode-dont-accept-var/36747
**Category:** micro:bit
**Tags:** javascript
**Created:** [May 17, 2025, 9:39pm UTC](https://forum.makecode.com/t/why-javascript-in-makecode-dont-accept-var/36747 "2025-05-17T21:39:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![BlueMoon2607](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bluemoon2607/32/17370_2.png) [@BlueMoon2607](https://forum.makecode.com/u/BlueMoon2607)
#### Post date: [May 17, 2025, 9:39pm UTC](https://forum.makecode.com/t/why-javascript-in-makecode-dont-accept-var/36747/1 "2025-05-17T21:39:33Z")

</div>

**const** and **let** are allowed as declaring variables, except for **var** , in _modified_ JavaScript. **var** is used to declare a variable, but you can redeclare it with this. You can use **var** with something like:

```auto
var jello = 3
var jello = 5
console.log(jello)

```

**const** and **let** work similarly, but you cannot redeclare, only change the value, but with **const** , you cannot change the value and redeclare it. Here is an example:

```auto
let jello = 5
console.log(jello)
let jello = 3 // Returns an error: Cannot redeclare block-scoped variable 'jello'.

const drink = 9
drink = 3 // Returns an error: Cannot assign to 'drink' because it is a constant or a read-only property. 

```

But here’s the big question: why does MakeCode’s JavaScript _never_ accept **var**? I was wondering if they were useless, but I think it makes it less flexible, which is problematic. Any ideas, guys?

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [May 17, 2025, 9:45pm UTC](https://forum.makecode.com/t/why-javascript-in-makecode-dont-accept-var/36747/2 "2025-05-17T21:45:59Z")

</div>

MakeCode does not use JavaScript. Rather, it uses TypeScript (and, to be precise, a variant called _static TypeScript_). The use of `var` is heavily discouraged in TypeScript.
