Por que no se usa mas “var” en javascript? ['SPA','ENG']

in #hive-1963878 months ago

Muchos de los desarrolladores cuando empiezan conocen u se encuentran con que existe la palabra reservada “var” para almacenar valores de variables, pero luego se preguntaran porque ya no se usa mas u se considera una mala práctica en el ámbito de desarrollo.
La respuesta es que se debe a que al utilizar esta variable no existe limitación de bloque, algo que ahora explicare con ejemplos.

Many developers when they start know or find that the reserved word “var” exists to store variable values, but then they will wonder why it is no longer used and is considered a bad practice in the development field. The answer is that it is because when using this variable there is no block limitation, something that I will now explain with examples.

scope.jpg

Scope Problem

scope2.jpg
Cuando uno habla sobre limitación u alcance, se refiere hasta donde se puede invocar u llamar dicha variable, en este caso hablo de variables y sé que hay otros tipos de métodos u funciones para invocar variables, pero aquí solo busco explicar sencillamente un caso particular.
Si la variable no posee limitación de bloque significa que aun estando dentro de algún método u función se puede llamar por fuera de la misma utilizando su mismo contenido y eso está mal, porque si uno crea una función que dentro tenga un único valor, traería problemas a futuro que esa variable pueda ser invocado fuera de la misma función y más si se puede alterar su contenido.

When one talks about limitation or scope, it refers to the extent to which said variable can be invoked or called. In this case I am talking about variables and I know that there are other types of methods or functions to invoke variables, but here I only seek to simply explain a particular case. If the variable does not have a block limitation, it means that even if it is inside a method or function, it can be called outside of it using its same content and that is wrong, because if one creates a function that has a single value inside, it would cause problems. In the future, that variable can be invoked outside of the same function and even more so if its content can be altered.
Real Problem
Sort:  

Congratulations @dobro2020! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 40000 upvotes.
Your next target is to reach 45000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.