Concepts or coding lessons of Salesforce that you can implement easily

Differences between var let and const in LWC

Here is Differences between var, let and const in LWC




Examples: 

if(true){
    var temp = 'Test LWC;
}
temp;

This will give output : Test LWC

if(true){
    let temp = 'Test LWC;
}
temp;

This will give output : Uncaught ReferenceError: temp is not defined at <anonymous>:4:1

if(true){
    const temp = 'Test LWC;
}
temp;

This will give output : Uncaught ReferenceError: temp is not defined at <anonymous>:4:1

if(true){
    const temp = 'Test LWC;
    temp = 'Test LWC Again';
}
temp;

This will give output : Uncaught TypeError: Assignment to constant variable


loading...

No comments:

Post a Comment