JavaScript Lesson 1: Introduction to JavaScript
Page 1: Overview of JavaScript
What is JavaScript?
o JavaScript is a programming language that allows you to create dynamic and interactive
web pages.
o It runs directly in the browser and interacts with HTML and CSS to enhance web
functionality.
Why Learn JavaScript?
o It’s a key language for web development.
o Essential for front-end frameworks (like React) and server-side development (like
Node.js).
o It’s versatile, used for both client and server applications.
Page 2: Setting up JavaScript
Tools You Need
o Text Editor: Visual Studio Code, Sublime Text, or any preferred text editor.
o Browser: Most browsers (Chrome, Firefox, etc.) have built-in developer tools to test your
JavaScript code.
Running JavaScript
o JavaScript can be written directly in an HTML file or in separate .js files.
o Example of linking a JavaScript file to an HTML file:
<html>
<head>
<title>My First JavaScript</title>
</head>
<body>
<h1>Welcome to JavaScript</h1>
<script src="script.js"></script>
</body>
</html>
Page 3: Basic Syntax
How to write your first JavaScript code:
JavaScript is case-sensitive and works using statements, expressions, and variables.
o Comments in JavaScript:
Single-line comments: // This is a comment
Multi-line comments:
/*
This is a
multi-line comment
*/
Displaying Output:
console.log(): Prints output to the browser console
Page 4: Variables and Data Types
Variables: Variables store data and can be declared using var, let, or const.
o var: Used for declaring variables (older, more flexible).
o let: Block-scoped, introduced in ES6 (useful for modern coding).
o const: Used to declare constant variables.
Example:
Data Types:
o String: Textual data (e.g., 'Hello World')
o Number: Numeric values (e.g., 42, 3.14)
o Boolean: Logical values (e.g., true or false)
o Undefined and Null: Special data types for empty or non-existent values.
Page 5: Simple Operations
Basic Arithmetic: JavaScript can perform basic arithmetic operations like addition, subtraction,
multiplication, and division.
Example:
String Concatenation: You can join two strings together using the + operator.
Example: