Day:3 - Introduction to JavaScript Variables

For checking 'console.log()'

Open the Developer Tools in your browser and click on the Console tab to see the output of your JavaScript code.

Short key: Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (Mac)

What is a Variable?

A Variable is a named container used to store data values in computer memory. Variables act like labeled storage boxes where we can save text, numbers, or conditions, and safely recall or change them later as your application runs.

Variable Types

  1. Declaring Variables & Initialization
  2. Reassigning Values with Let
  3. Variable Case Sensitivity
  4. The camelCase Naming Convention
  5. Reserved Keywords Constraint
  6. Valid Starting Characters

1. Declaring Variables & Initialization

Creating a variable in JavaScript requires a specific keyword tool like let or const followed by a custom name. Assigning a value to that newly created name using the equals sign (=) is called initialization.

2. Reassigning Values with Let

The main advantage of using the let keyword is that its stored value remains flexible. Reassignment means replacing the existing value inside the container with a brand-new value later in your code program without using the 'let' keyword again.

3. Variable Case Sensitivity

JavaScript is strictly case-sensitive. This means spelling a container variable name with matching letters but different casing layouts (like lowercase vs uppercase letters) creates entirely separate containers in computer storage.

4. The camelCase Naming Convention

When creating descriptive names using multiple words, JavaScript developers utilize camelCase. The first complete word is kept lowercase, and the first letter of every connected word that follows must start with a capital letter.

5. Reserved Keywords Constraint

There are certain built-in words that JavaScript saves exclusively for its own internal language logic engines. You cannot use reserved names like let, const, function, or if as variable handles.

6. Valid Starting Characters

Variable names must begin with a letter, an underscore (_), or a dollar sign ($). They cannot start with digits or contain general punctuation marks like dashes or exclamation tags.