Skip to main content

Javascript-basics:
Variables

image for Variables

Variables

Variables are used to store and manage data. You can think of a variable as a named container that holds a value. This value can be a number, string, object, or any other data type. Variables provide a way to store information in your program and reference it later. When we declare a variable it looks like this: var name = viv;.

In Javascript, const is a keyword used to declare a constant variable. Once a variable is defined with const, its value cannot be reassigned. However, it's important to note that const does not make the variable itself immutable; it only prevents reassignment of the variable reference. Use const when you want to ensure that a variable's value remains constant throughout its scope.