Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

var in js

I love you
Comment

js var

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
Comment

js var

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

js var

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

// è come dire:

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

functions and 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  ')
Comment

js var

use let instead of var !!!
Comment

js var

var a = 0, b = 0;
Comment

js var

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ù.
Comment

js var

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

js var

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

javascript define variable

var variable1 = "some variable content";
Comment

var function js

hi = () => {}
Comment

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!
Comment

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...".
Comment

var javascript

 var text = "";
var i;
for (i = 0; i < 5; i++) {
  text += "The number is " + i + "<br>";
} 
Comment

vars javascript

var /*var*/ = /*What it does*/
Comment

js var

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: gitea 
Javascript :: javascript.loop 
Javascript :: download canvas to png 
Javascript :: javascript move element position 
Javascript :: object.assign 
Javascript :: java script removing first three indexes 
Javascript :: how to convert json to object 
Javascript :: js get array object from local storage 
Javascript :: node.js folder structure 
Javascript :: hrtime to milliseconds 
Javascript :: scroll position 
Javascript :: add new value to array of object javascript using spread 
Javascript :: react native dynamic style 
Javascript :: requestanimationframe in javascript 
Javascript :: loop for of 
Javascript :: julia function 
Javascript :: add role command discord.js 
Javascript :: where to create service angularor nodejs 
Javascript :: Bracket Notation Example 
Javascript :: js if 
Javascript :: Hint:“javascript sleep 1 second” is a pretty common code problem that people search ;-) 
Javascript :: fetch not working javascript 
Javascript :: router react how to pass data to class component 
Javascript :: using settings_data.json shopify 
Javascript :: tradingview custom data feed 
Javascript :: how to create a web browser in javascript 
Javascript :: luxurious 
Python :: python shebang 
Python :: remove all pyc 
Python :: how to open any program on python 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =