<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/JXLNTKXIl" -->

---
title: var, let, and const in JavaScript: a cheatsheet. | daily.dev
description: The var statement declares a variable in JavaScript which abides to the following rules:. function-scoped or globally-scope Accidental global variables...
canonical: https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: var, let, and const in JavaScript: a cheatsheet. | daily.dev
og:description: The var statement declares a variable in JavaScript which abides to the following rules:. function-scoped or globally-scope Accidental global variables...
og:url: https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil
og:image: https://api.daily.dev/og/posts/JXLNTKXIl.png
og:image:alt: var, let, and const in JavaScript: a cheatsheet.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# var, let, and const in JavaScript: a cheatsheet.

**[RUBYLAND](https://daily.dev/sources/rubyla)** · 3 min read · 14 upvotes · 1 comments

## Summary

The var statement declares a variable in JavaScript which abides to the following rules:. function-scoped or globally-scope Accidental global variables reassignable and redeclared. let Block scoped Temporal dead zone Reassignable, not redeclarable.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.valentinog.com/blog/var/>

## Community discussion

Top comments from developers on daily.dev.

**@alinmigea** · 4 upvotes

> really useful

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#logging](https://daily.dev/tags/logging)

[View this post on daily.dev](https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"var, let, and const in JavaScript: a cheatsheet.","url":"https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil"},"datePublished":"2020-09-03T00:55:48.707Z","dateModified":"2021-10-07T14:17:10.317Z","description":"The var statement declares a variable in JavaScript which abides to the following rules:. function-scoped or globally-scope Accidental global variables...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/64cc19904a79222bc31cf11bee381b21","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/64cc19904a79222bc31cf11bee381b21","isAccessibleForFree":true,"articleSection":"RUBYLAND","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"RUBYLAND","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/rubyla","url":"https://daily.dev/sources/rubyla"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"javascript,logging","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"RUBYLAND","item":"https://daily.dev/sources/rubyla"},{"@type":"ListItem","position":3,"name":"var, let, and const in JavaScript: a cheatsheet."}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/var-let-and-const-in-javascript-a-cheatsheet--jxlntkxil","comment":[{"@type":"Comment","text":"really useful","datePublished":"2020-09-03T10:40:13.260Z","url":"https://daily.dev/posts/JXLNTKXIl#c-821fNPcnn","author":{"@type":"Person","name":"Alin Migea","url":"https://daily.dev/alinmigea","image":"https://media.daily.dev/image/upload/s--s9V587rX--/f_auto/v1777369296/avatars/avatar_37e8000ffec0491a876efefa86befe28?_a=BAMAMiWQ0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}}]}
```

