Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,185 members, 7,818,599 topics. Date: Sunday, 05 May 2024 at 07:35 PM

Difference Between Var, Let And Const Keywords In Javascript - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Difference Between Var, Let And Const Keywords In Javascript (405 Views)

Javascripters: Telegram Group To All Interested In Javascript And Its Ecosystem / How To Retrieve Data From An Api Using Fetch Api In Javascript / How Do I Convert Object To Arrey In Javascript (2) (3) (4)

(1) (Reply)

Difference Between Var, Let And Const Keywords In Javascript by HiNode(m): 2:04pm On Aug 18, 2022
Difference between var, let and const keywords in JavaScript

In JavaScript, users can declare a variable using 3 keywords that are var, let, and const. In this article, we will see the differences between the var, let, and const keywords. We will discuss the scope and other required concepts about each keyword.

var keyword in JavaScript: The var is the oldest keyword to declare a variable in JavaScript.

var is lexically scoped meaning when declare, you can assess it any where in your code and it
Can be reassigned to another variable.

let keyword in JavaScript: The let keyword is an improved version of the var keyword.
Scope: block scoped: The scope of a let variable is only block scoped. It can’t be accessible outside the particular block.
Blocks like (if) block and (for loop) block.

const keyword in JavaScript: The const keyword has all the properties that are the same as the let keyword, except the user cannot update it.

It is also a block scoped: When users declare a const variable, they need to initialize it, otherwise, it returns an error. The user cannot update the const variable once it is declared.


#learnjavascript

If you gain something from this, kindly help me view my gig page and make impression
https://www.fiverr.com/share/xjD32l

Follow me on twitter @Tmobytech
Re: Difference Between Var, Let And Const Keywords In Javascript by HiNode(m): 6:56am On Aug 19, 2022
Javascript is in high demand now, #learnjavaScript

(1) (Reply)

Sometimes It Doesn't Matter What Language / How Dangerous Could A Cyber Security Career Get / UX/UI Designer At Centricity Insights

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.