0% found this document useful (0 votes)
27 views14 pages

Web Technology - JAVASCRIPT

Web Technology - JAVASCRIPT

Uploaded by

vijayalakshmis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views14 pages

Web Technology - JAVASCRIPT

Web Technology - JAVASCRIPT

Uploaded by

vijayalakshmis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

WEB TECHNOLOGY

Presented By
S.Vijayalakshmi B.E,
Assistant Professor,
Department of Computer Science,
Sri Sarada Niketan College for Women, Karur.
Introduction to JavaScript
Definition: JavaScript is a high-level, interpreted
programming language primarily used for web
development.
Key Features:
• Interactivity: Enhances user interactions on websites.
• Versatile: Used for both client-side and server-side
programming.
• Dynamic Typing: Variables don't require a defined type at
the time of declaration.
• Event-Driven: Responds to user actions like clicks,
JavaScript Syntax
Basic Syntax Rules:
• Statements: End with semicolons (optional in some cases).
• Variables: Declared with var, let, or const.
• Functions: Defined using the function keyword or as arrow
functions.
• Example:
let greeting = "Hello, World!";
console.log(greeting);

// Outputs: Hello, World!


Language Elements - Variables and Data Types
Variables in JavaScript:
• var: Function-scoped, can be redeclared.
• let: Block-scoped, no redeclaration.
• const: Block-scoped, cannot be reassigned.
Data Types in JavaScript:
• Primitive Types: Number, String, Boolean, Undefined, Null,
Symbol, BigInt
• Non-Primitive Types: Object (including Arrays, Functions)
• Example:
let age = 25; // Number
const name = "John"; // String
Operators in JavaScript
Types of Operators:
• Arithmetic Operators: +, -, *, /, %
• Comparison Operators: ==, ===, !=, >, <, >=, <=
• Logical Operators: &&, ||, !
• Assignment Operators: =, +=, -=, *=, /=
Example:
let x = 5;
let y = 10;
console.log(x + y);

// Outputs: 15
Control Flow - Conditions and Loops

Conditional Statements:
if, else, else if, switch
Example:
let score = 85;
if (score > 90) {
console.log("A");
} else if (score > 80) {
console.log("B");
}
JavaScript Objects

Definition: An object is a collection of key-value pairs


(properties and methods).
Creating Objects:
• Literal notation: {}
Accessing Object Properties:
• Using dot notation: person.name
• Using bracket notation: person['age']
• Methods in Objects: Functions defined within an object
are called methods.
Loops:

for, while, do...while


Example:
for (let i = 0; i < 5; i++) {
console.log(i);
}

// Outputs: 0 1 2 3 4
Other Built-in JavaScript Objects

Common Built-in Objects:


• Date: For working with dates and times.
• Math: Provides mathematical constants and functions.
• String: Offers string manipulation methods (e.g.,
substring(), toUpperCase()).
• Number: Used for numerical operations and conversions.
• JSON: For parsing and stringifying JSON data.
Arrays in JavaScript

Definition: Arrays are ordered collections of values, which


can be of any data type.
Creating Arrays:
• Literal notation: []
• Using new Array() constructor.
Example:
let fruits = ["Apple", "Banana", "Cherry"];
Array Methods

Common Array Methods:


• push() – Adds an item to the end.
• pop() – Removes the last item.
• shift() – Removes the first item.
• unshift() – Adds an item to the beginning.
• forEach() – Iterates through the array.
Advanced Array Methods

• map() – Creates a new array by applying a function to


each element.
• filter() – Creates a new array with elements that pass a
condition.
• reduce() – Reduces the array to a single value
Array Methods

Example:
let nums = [1, 2, 3, 4];
let doubled = nums.map(num => num * 2);
console.log(doubled);

Outputs: [2, 4, 6, 8]
THANK YOU

You might also like