js var

var a;
console.log(a);                // scrive in console "undefined" o "" a seconda del browser usato.
console.log('still going...'); // scrive in console "still going...".

4
10
Awgiedawgie 440220 points

                                    var nomevariabile1 [= valore1] [, nomevariabile2 [= valore2] ... [, nomevariabileN [= valoreN]]];

4 (10 Votes)
0
3.86
7
Awgiedawgie 440220 points

                                    console.log(a);                // Genera un ReferenceError.
console.log('still going...'); // Non verrà eseguito.

3.86 (7 Votes)
0
3.5
4
Awgiedawgie 440220 points

                                    var a = 1;
b = 2;

delete this.a; // Genera un TypeError in strict mode. Altrimenti fallisce senza generare messaggi.
delete this.b;

console.log(a, b); // Genera un ReferenceError.
// La proprietà 'b' è stata cancellata e non esiste più.

3.5 (4 Votes)
0
3.88
8
Phoenix Logan 186120 points

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

// è come dire:

var a, b = a = 'A';

3.88 (8 Votes)
0
3
1
Phoenix Logan 186120 points

                                    function x() {
  y = 1;   // Genera un ReferenceError in strict mode
  var z = 2;
}

x();

console.log(y); // scrive "1" in console
console.log(z); // Genera un ReferenceError: z non è definita fuori dalla funzione x

3 (1 Votes)
0
3.7
10
A-312 69370 points

                                    var x = y, y = 'A';
console.log(x + y); // non definito

3.7 (10 Votes)
0
4.5
2
Lionel Aguero 33605 points

                                    var a = 0, b = 0;

4.5 (2 Votes)
0
4.33
6
Phoenix Logan 186120 points

                                    var x = 0;  // x è dichiarata dentro l'ambiente file, poi le è assegnato valore 0

console.log(typeof z); // undefined, poichè z ancora non esiste

function a() { // quando a è chiamata,
  var y = 2;   // y è dichiarata dentro l'ambiente della funzione a, e le è assegnato valore 2

  console.log(x, y);   // 0 2

  function b() {       // quando b è chiamata
    x = 3;  // assegna 3 all'esistente ambiente x, non crea una nuova variabile globale
    y = 4;  // assegna 4 all'esistente esterna y, non crea una nuova variabile globale
    z = 5;  // crea una nuova variabile globale z e le assegna valore 5.
  }         // (Throws a ReferenceError in strict mode.)

  b();     // chiamare b crea z come variabile globale
  console.log(x, y, z);  // 3 4 5
}

a();                   // chiamando a si richiama b
console.log(x, z);     // 3 5
console.log(typeof y); // non definito, perchè y è locale alla funzione a

4.33 (6 Votes)
0
3.86
7
A-312 69370 points

                                    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!

3.86 (7 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
vars javascript javascript var javascript $ variable var keyword javascript variable ? javascript !!var javascript what is javascript var javascript $var #var in javascript var definition javascript var i in javascript what is var in javascript js var ? var : var var in js variable In JavaScript {variable} javascript variable in js java script variable javascript variable ? : js var? ${var} javascript var js declaring var in js should you use var in javascript $ var in javascript how to use var in javascript variables in javscript use var in javascript what are variables in javascript var en javascript variables in javascript var javasript "{variable}" js javascript var function javascrtipy var javascript var new js variables vars in js how to declare a var in js +var in javascript var ? : javascript what is variable javascript what is var i in javascript var() what is var a=[] in js javascript variables js declare variables declare var in javascript var as js variables in js js with variable javscript variable var javascript js declare variable what is var: {} in javascript js variable when to use var in javascript ajavascript variables javascript variables variables js when to use var js variable js what is use of var in javascript vara js what are variables in javascript variables javascript how to make a var in js javascript var[] = what is var javascript js variables var in js what is var js should we use var in javascript should I use var in js javascript var ? var : var var $ javascript var in javascript how does var work in js Javascript $variable var value in javascript create var in js js what is _var js variable ? js ! var js {...var} [, var] javascript var javascript javascript var $ what is var in js when to use var in js how to use js var in js variable javascript var variable javascript using var in js var = var = var javascript js var function javascript variable new var javascript var javscript "??" javascript variable how to set a var in javascript using :var in js variable .js var "{ }" javascript js var = [{}] java script variables js variable in html how to make variable in javascript var use in js {} westing var in js types of variables in javascript declare a variable in js can you have a . in varible js js var w3school how use javascript variable in hmtl variable javascript definition var statement in javascript html javascript defining var js declare variable from string statement in javascript with var javascript var x = (); js variable in html variabley with ? javascript js var variable = variable javascript declaration in javascript var x = 1 javascript javascript variable variables define "i" in variable in javascript !var in js what is declaring a variable javascript var variable function to set value of variable in javascript declare var script var var of javascript variable assignment javascript creating variable in javascript js string + variable variable '-variable' in js
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source