Basic Syntax

JavaScript uses a C-style syntax with curly braces for code blocks, semicolons to terminate statements, and a dynamic type system that allows variables to hold any type of value.

let message = "Hello, World!";
const PI = 3.14159;

console.log(message);
console.log(`The value of PI is approximately ${PI}`);

In this chapter, you will learn the basic syntax of JavaScript, including how to declare variables, work with different data types, perform basic operations with strings and numbers, and use console logging to output information.

Learning Outcomes

  • Write valid JavaScript statements using correct syntax, identifiers, and comments
  • Declare and work with variables, including the differences between let, const, and var
  • Distinguish between primitive types and objects, and check types at runtime
  • Work with strings and numbers, including literals, template literals, and common methods
  • Use arithmetic operators and explain how type coercion affects their results
  • Use console logging to output and debug information

Sections

  1. Console Logging
  2. Variables
  3. Syntax Rules
  4. Data Types
  5. String Basics
  6. Numbers
  7. Arithmetic Operators
  8. Practice Questions