top of page

Upskilling Exams

Public·11 members

var vs let vs const in JavaScript – Complete Beginner Guide

  • var is the old JavaScript keyword, function-scoped, and allows redeclaration and updating of values.

  • var is hoisted and can create bugs, so it is not recommended in modern JavaScript.

  • let is block-scoped, cannot be redeclared in the same block, and is used for variables whose values may change.

  • let is safer than var because it respects block scope and avoids accidental redeclarations.

  • const is block-scoped like let but its value cannot be changed or redeclared after assignment.

  • Use const for fixed values and let for changeable values; avoid var in modern code.

6 Views

In JavaScript, you will often hear the terms function and method, and although they look similar, they are not the same. A function is an independent block of code that performs a specific task. A method is a function that belongs to an object. When a function is defined inside an object and accessed using the dot (.) notation, it becomes a method.

13 Views
Ashwani Sharma
26 days ago · joined the group.
20 Views
MISHRA PWN
27 days ago · joined the group along with .
25 Views
bottom of page