“Różnica między let i var w JavaScript” Kod odpowiedzi

Różnica między let i var w JavaScript

//let
1. It is block-scoped.
2. It does not allow to redeclare variables.	
3. Hoisting does not occur in let.
// var 
1. It is function scoped.
2. It allows to redeclare variables.
3. Hoisting occurs in var.
Tiny Coders

JS var vs let

let = 10 // accessable only in defined scope
var = 10 // accessable in the function it is declared in (global variable in a function)
  
katanton reckless

Różnica pozwól i var

------------------Differences------------------		var			let
Global Scope										Yes			No
Can be changed outside statement where made in		Yes			No
Block Scope											No			Yes
Armandres

Czego użyć LET VAR JS

/* DIFFERENCE BETWEEN LET AND VAR */

//LET EXAMPLE
{
  let a = 123;
};

console.log(a); // undefined

//VAR EXAMPLE
{
  var a = 123;
};

console.log(a); // 123
Excited Eel

Różnica między „Let” i „var”?

In simple words 'var' is function scoped and 'let' is block scoped
Undefined

Odpowiedzi podobne do “Różnica między let i var w JavaScript”

Pytania podobne do “Różnica między let i var w JavaScript”

Więcej pokrewnych odpowiedzi na “Różnica między let i var w JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu