# New mode, which abolishes "let" and "var" words

**URL:** <https://es.discourse.group/t/new-mode-which-abolishes-let-and-var-words/297>\
**Category:** 💡 Ideas\
**Created:** [April 7, 2020, 12:42pm UTC](https://es.discourse.group/t/new-mode-which-abolishes-let-and-var-words/297 "2020-04-07T12:42:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaroslav.tavgen](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jaroslav.tavgen/32/2732_2.png) [@jaroslav.tavgen](https://es.discourse.group/u/jaroslav.tavgen)\
**Post date:** [April 7, 2020, 12:42pm UTC](https://es.discourse.group/t/new-mode-which-abolishes-let-and-var-words/297/1 "2020-04-07T12:42:25Z")

</div>

I would propose a new mode (like "use strict"). In this mode, If you type "foo = 3", and you have typed "foo" for the first time in the scope, then it would be equal to you typing "let foo = 3". If it is done inside the function, then "foo" would not be added to global scope, and window.foo would not be created.

How it would work:

Today the following code:

function foo(){  
bar = 5;  
}  
let bar = 3;  
foo();  
console.log(bar) // 5

prints "5" in the console.

I would suggest the following:

"use new mode"  
function foo(){  
bar = 5; // equals "let bar = 5"  
}  
let bar = 3;  
foo();  
console.log(bar) // 3

Prints "3" on the console.

What this will give:

1. Faster software development as we will not write "let" everywhere. We can abolish words "var" and "let" as such, and only leave the "const" word.  
2). This should work only in "new mode", because otherwise back compatibility would be broken.

---

<div class="post-metadata">

**Author:** ![bergus](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/bergus/32/152_2.png) [@bergus](https://es.discourse.group/u/bergus)\
**Post date:** [April 7, 2020, 1:06pm UTC](https://es.discourse.group/t/new-mode-which-abolishes-let-and-var-words/297/2 "2020-04-07T13:06:10Z")

</div>

Hi,  
I don't think avoiding to press 4 keys will make software development faster, especially if you factor in the slowdown that having to search for a variable declaration when reading code will cause.  
Personally I already experienced this when developing Python, where scoping and variable definitions works quite similarly to what you suggest. Deeply nested scopes, as they are typical in code with many closures in JavaScript, are a mess in Python - especially if you want to assign to a higher-scope variable, you explicitly have to declare it as `nonlocal` to prevent it from creating a new local variable that shadows the outer one.

---

<div class="post-metadata">

**Author:** ![claudiameadows](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/claudiameadows/32/126_2.png) [@claudiameadows](https://es.discourse.group/u/claudiameadows)\
**Post date:** [April 9, 2020, 6:46pm UTC](https://es.discourse.group/t/new-mode-which-abolishes-let-and-var-words/297/3 "2020-04-09T18:46:37Z")

</div>

CoffeeScript is even worse - you don't have the escape hatch and so you get 13 billion variables in your autocomplete as you try to work around it.

But yeah, I agree, 4 extra key presses isn't going to help much. (And if you're writing on a non-Latin keyboard, it's maybe 2 extra key chords on top of that, but you already have to do that just for other basic syntax.)

---

<div class="post-metadata">

**Author:** ![vrugtehagel](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/vrugtehagel/32/653_2.png) [@vrugtehagel](https://es.discourse.group/u/vrugtehagel)\
**Post date:** [March 10, 2021, 2:49pm UTC](https://es.discourse.group/t/new-mode-which-abolishes-let-and-var-words/297/4 "2021-03-10T14:49:46Z")

</div>

I agree with the above comments, and would like to add that `const` (for me, anyways, and I know for a lot of other developers as well) is by far the most used compared to `var` and `let`. I rarely ever see `var` outside an IE11-compatible environment, and variables aren't reassigned as much as they are not. This new mode would, for the most part, not change much code-wise, but it would create confusion having to differentiate between the two modes.
