JavaScript Tutorial

Variables, Types and Operators

Use const, let, primitive values, objects, comparison and logical operators.

Concept

Prefer const for bindings that are not reassigned and let when reassignment is necessary. Avoid introducing var in new code unless you are specifically learning its legacy function-scoping behavior.

JavaScript uses dynamic types. Strict equality with === avoids many coercion surprises and is usually a clearer default than loose equality.

Example

const course = "JavaScript";
let lessons = 6;
const active = true;
console.log(course, lessons, active);
console.log(lessons === 6);
Type the example yourself and change at least one value. Small experiments reveal syntax and behavior faster than passive reading.

Practice Tasks

  1. Create const values for name and city.
  2. Use let for a counter that changes.
  3. Compare 5 and \"5\" with both == and === and explain the result.

Key Takeaways

  • const and let are block-scoped.
  • Types belong to values.
  • Prefer strict equality for predictable comparisons.