Register for our webinar

How to Nail your next Technical Interview

1 hour
Loading...
1
Enter details
2
Select webinar slot
*Invalid First Name
*Invalid Last Name
*Invalid Phone Number
By sharing your contact details, you agree to our privacy policy.
Select your webinar time
Step 1
Step 2
Congratulations!
You have registered for our webinar
Oops! Something went wrong while submitting the form.
1
Enter details
2
Select webinar slot
Step 1
Step 2
Confirmed
You are scheduled with Interview Kickstart.
Redirecting...
Oops! Something went wrong while submitting the form.
Iks white logo

You may be missing out on a 66.5% salary hike*

Nick Camilleri

Head of Career Skills Development & Coaching
*Based on past data of successful IK students
Iks white logo
Help us know you better!

How many years of coding experience do you have?

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Our June 2021 cohorts are filling up quickly. Join our free webinar to Uplevel your career
close
closeAbout usWhy usInstructorsReviewsCostFAQContactBlogRegister for Webinar

Attend our Free Webinar on How to Nail Your Next Technical Interview

WEBINAR +LIVE Q&A

How To Nail Your Next Tech Interview

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings

Difference Between var, let and const Keywords in JavaScript

Attend our Free Webinar on How to Nail Your Next Technical Interview

WEBINAR +LIVE Q&A

How To Nail Your Next Tech Interview

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings

Difference Between var, let and const Keywords in JavaScript

## Introduction JavaScript is an object-oriented scripting language that is used to develop web applications. It has a set of keywords that are used to create, store, and manipulate variables in the code. `var`, `let` and `const` are the three keywords that are used to declare a variable in JavaScript. The main difference between `var`, `let` and `const` is their scope and the way they are used. `var` is a keyword that is used to declare a variable, which has a global scope, meaning it can be accessed from anywhere in the code. `let` is a keyword that is used to declare a variable with a block scope. It can be accessed only within the block it is declared in. `const` is a keyword that is used to declare a constant variable, which has a block scope and cannot be reassigned. In this article, we will be discussing the differences between `var`, `let` and `const` keywords in JavaScript and the best way to use them. We will also look at some of the advantages and disadvantages of using each keyword.

Worried About Failing Tech Interviews?

Attend our webinar on
"How to nail your next tech interview" and learn

Hosted By
Ryan Valles
Founder, Interview Kickstart
Our tried & tested strategy for cracking interviews
How FAANG hiring process works
The 4 areas you must prepare for
How you can accelerate your learnings
Register for Webinar
# Var, Let and Const Keywords in JavaScript The three keywords `var`, `let` and `const` are used in JavaScript to declare variables. The differences between them are important to understand in order to use them appropriately in your code. ## Var `Var` is the oldest keyword for declaring variables in JavaScript and was introduced in the first version of the language. Variables declared with `var` are considered to have **function scope**, meaning that they are accessible within the function in which they were declared. If a variable is declared outside of a function, it will be accessible throughout the entire program. ## Let `Let` was introduced in ES6 and is similar to `var`, but with the addition of **block scope**. Variables declared with `let` are accessible only within the block in which they were declared, for example a for loop or an if statement. ## Const `Const` was also introduced in ES6 and is used to declare **immutable** variables. This means that any variable declared with `const` cannot be reassigned or redeclared. ## Sample Code Here is an example of how each variable type can be used: ```javascript // Var var x = "Hello World!"; console.log(x); // Prints "Hello World!" // Let let y = 10; console.log(y); // Prints 10 // Const const z = true; console.log(z); // Prints true ```