“Variable JavaScript” Código de respuesta

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

Variables de JavaScript

// here are the ways to define variables
var x = "hi"; // for global variables
let x = "hi"; // for block-scoped variables
const x = "hi"; // for block-scoped variables which can not be reassigned
The Cat Coder

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

Variable JavaScript

// This is best way to make a variable
// Varibales Store Data
var variable1 = 56;
//OR
var variable2 = true;

var variable3 = "Hello World";
Technical Gamer

Variable JavaScript

var myString = "string"; //var can be redefined
var myInt = 34; //var can be redefined
const myString2 = "string"; //const cannot be redefined
const myInt2 = 69; //const cannot be redefined
Cute Chimpanzee

Variable JavaScript

var variable = "Hello World";
Insert_Name_Here

Respuestas similares a “Variable JavaScript”

Preguntas similares a “Variable JavaScript”

Más respuestas relacionadas con “Variable JavaScript” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código