Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

difference between let and var in javascript

//let
1. It's used in block-scoped.
2. It does not allow to redeclare variables.	
3. Hoisting does not occur in let.
// var 
1. It's used in function scoped.
2. It allows to redeclare variables.
3. Hoisting occurs in var.
Comment

var vs let js

let: //only available inside the scope it's declared, like in "for" loop, 
var: //accessed outside the loop "for"
Comment

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

what to use let vs 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
Comment

var vs let javascript

var makes a grobal variable
let makes a local variable
Comment

PREVIOUS NEXT
Code Example
Javascript :: higher order function javascript 
Javascript :: array methods in javascript 
Javascript :: why null is object in javascript 
Javascript :: change string to int javascript 
Javascript :: moment duration 
Javascript :: switch 
Javascript :: sort list in javascript 
Javascript :: npm google map react 
Javascript :: angular cli command to create component without spec 
Javascript :: check leap year 
Javascript :: javascript return multiple values 
Javascript :: chatbot js 
Javascript :: how to add prefix to a string in javascript 
Javascript :: leaflet limit map panning 
Javascript :: how to run react app on apache server 
Javascript :: javascript Implicit Boolean Conversion to Number 
Javascript :: javascript Adding Element to the Inner Array 
Javascript :: javascript map size 
Javascript :: javascript Assigning to a getter-only property is not allowed 
Javascript :: react destructuring with rename 
Javascript :: what is hmr in console 
Javascript :: remoteevent dont send object 
Javascript :: set display size phaser 
Javascript :: phaser rotate around 
Javascript :: regular expression a-z and 0-9 
Javascript :: how to invoke a function in a class 
Javascript :: filter text js 
Javascript :: mogoose schema to add json as a property 
Javascript :: react native version 
Javascript :: js brightness 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =