Depends on the javascript version.
If you use JS5 (the standard in browsers) var
is the keyword used to declare a variable. Ex:
var miVariable, otraVariableInicializada=1,
otraVariableUndefined;
Now if you use Javascript 6 (ECMAScript 2015) or higher (NodeJS), the keyword var
has fewer uses.
In general, use the const
(for constants and functions) or let
(for variables) unless you need to create a closure , in which case var
should be used.
const modulo = require('modulo');
const miFunc = () => {
var enClousure = 1234;
return () => {
let valorLocal = modulo.getAlgo();
return enClousure + valorLocal;
};
};