“fonction var js” Réponses codées

js var

var x = 0;

function f() {
  var x = y = 1; // x è dichiarata localmente. y invece no!
}
f();

console.log(x, y); // Genera un ReferenceError in strict mode (y non è definita). 0, 1 altrimenti.
// In modalità non-strict mode:
// x è la globale come si ci aspettava
// però, y è uscita fuori dalla funzione!
DevLorenz02

var javascript

var is a keyword to define the varible in js but as of es-6 we, use let and const keywords for the same
Xerothermic Xenomorph

js var

var a = 'A';
var b = a;

// è come dire:

var a, b = a = 'A';
DevLorenz02

fonctions et variables javascript

/*A function is like an operation, you pass two or more values/variables 
into it, it will output a value (if return is used).
Also, you will not have to redeclare the parameters if you used arguments. */

/* A global variable can be accessed anywhere including in curly braces { }.
You do not have to list them as an argument however it is recommended */

/*            | scroll down |
              v             v     */

/* You will opt a global variable into an argument if
you want it to become a different variable in the function */

/*Use*/ let /*and*/ const /*more often because it will not allow you to
declare it again*/

/*Parameters are like the placeholder variables for the variables
outside the function being used as arguments*/

// Local variables(like in functions) take priority over global variables

/*The */return/* operator will output a value such as */ 4, "string", 
true /*etc. this will not be assigned to a variable unless you do assign it
yourself. */

/*If a*/ return /*operator is not used  it will change the global variable 
instead (if there is one).*/

// A good explenation on global and local variables is below
('  https://www.youtube.com/watch?v=iJKkZA215tQ  ')
Shiny Salmon

js var

var a = 0, b = 0;
DevLorenz02

fonction var js

hi = () => {}
Doubtful Dotterel

Réponses similaires à “fonction var js”

Questions similaires à “fonction var js”

Plus de réponses similaires à “fonction var js” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code