JavaScript_Topics
JavaScript_Topics
A scripting language is a programming language used to write scripts that automate tasks. JavaScript is a
popular scripting language used mainly for web development to create interactive and dynamic web pages.
JavaScript is executed in the browser, allowing developers to control HTML content, validate forms, and
create animations.
Internet - Concepts and Overview
**Client-Side Scripting**:
**Server-Side Scripting**:
Advantages of JavaScript
Features of JavaScript
Keywords
JavaScript has reserved words called **keywords** which are part of the syntax.
Examples:
Variables
Declaration methods:
```javascript
var x = 5;
let y = 10;
const z = 15;
```
Data Types
Example:
```javascript
let x; // Undefined
```
Internet - Concepts and Overview
Constants
Example:
```javascript
const PI = 3.14159;
```
Comments
**Single-line comment**:
```javascript
// This is a comment
```
**Multi-line comment**:
```javascript
/* This is
a multi-line comment */
```
Internet - Concepts and Overview
**if statement**:
```javascript
if (x > 0) {
console.log("Positive");
```
**if-else**:
```javascript
if (x > 0) {
console.log("Positive");
} else {
console.log("Not positive");
```
**switch**:
```javascript
switch(day) {
```
Internet - Concepts and Overview
**for loop**:
```javascript
console.log(i);
```
**while loop**:
```javascript
let i = 0;
while (i < 5) {
console.log(i);
i++;
```
**do-while loop**:
```javascript
let i = 0;
do {
console.log(i);
i++;
```
Internet - Concepts and Overview
```javascript
if (i === 3) break;
console.log(i);
```
```javascript
if (i === 3) continue;
console.log(i);
```