0% found this document useful (0 votes)
2 views8 pages

AKTU JavaScript Notes

This document serves as a comprehensive guide to JavaScript for AKTU B.Tech CSE/IT students, covering key topics such as Client-Side Scripting, DOM Manipulation, Event Handling, and ES6+ features. It includes detailed explanations of JavaScript fundamentals, control flow, functions, asynchronous programming, and error handling, along with practical examples. Additionally, it features revision questions to aid in exam preparation.

Uploaded by

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

AKTU JavaScript Notes

This document serves as a comprehensive guide to JavaScript for AKTU B.Tech CSE/IT students, covering key topics such as Client-Side Scripting, DOM Manipulation, Event Handling, and ES6+ features. It includes detailed explanations of JavaScript fundamentals, control flow, functions, asynchronous programming, and error handling, along with practical examples. Additionally, it features revision questions to aid in exam preparation.

Uploaded by

Vison and C rule
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Comprehensive Notes

Target: AKTU [Link] CSE/IT (KCS-602)

Overview: This document covers the essential modules of JavaScript as per the
AKTU syllabus, focusing on Client-Side Scripting, DOM Manipulation, Event
Handling, and modern ES6+ features.

Unit 1: Introduction to JavaScript

JavaScript is a versatile, high-level, interpreted programming language primarily used


for creating interactive web pages. It was developed by Brendan Eich at Netscape in
1995.

Key Features

• Interpreted: Code is executed line by line without prior compilation.

• Lightweight: Small footprint, making it ideal for browser-based execution.

• Multi-paradigm: Supports object-oriented, imperative, and functional


programming.

• Dynamic Typing: Variables can hold any data type, and the type can change
during execution.

Client-Side vs Server-Side

Client-Side: JavaScript runs in the user's browser (Chrome, Firefox, etc.). It handles UI
logic, form validation, and animations.
Server-Side: JavaScript runs on the server (using [Link]). It handles database
connections, API logic, and server management.

AKTU JavaScript Study Guide (KCS-602) Page 1


Unit 2: Fundamentals & Syntax

Variables (var, let, const)

Modern JavaScript (ES6) introduced block-scoped variables to replace the functional-


scoped var.

// Variable Declaration
var name = "AKTU"; // Function scoped (Avoid in modern JS)
let age = 25; // Block scoped (Mutable)
const PI = 3.14; // Block scoped (Immutable)

Data Types

1. Primitive: Number, String, Boolean, Null, Undefined, Symbol, BigInt.

2. Non-Primitive (Reference): Objects, Arrays, Functions.

Operators

JavaScript supports standard operators including Arithmetic (+, -, *, /), Comparison


(==, ===, !=, !==), and Logical (&&, ||, !).

// Strict Equality vs Equality


5 == "5" // true (checks only value)
5 === "5" // false (checks value and data type)

Unit 3: Control Flow

Control structures allow the script to make decisions and repeat tasks.

AKTU JavaScript Study Guide (KCS-602) Page 2


Conditional Statements

if (marks > 40) {


[Link]("Pass");
} else {
[Link]("Fail");
}

Loops

• for loop: Traditional iteration.

• while loop: Condition-based iteration.

• for...in: Used to iterate over properties of an object.

• for...of: Used to iterate over iterable objects like Arrays.

Unit 4: Functions & Hoisting

Functions are the building blocks of JavaScript. They can be defined in multiple ways.

Function Declarations vs Expressions

// Declaration (Hoisted)
function greet() { return "Hello"; }

// Expression (Not Hoisted)


const sayHi = function() { return "Hi"; };

// Arrow Function (ES6)


const add = (a, b) => a + b;

AKTU JavaScript Study Guide (KCS-602) Page 3


Hoisting

Hoisting is a JavaScript mechanism where variables and function declarations are


moved to the top of their containing scope before code execution. Only declarations
are hoisted, not initializations.

Unit 5: Document Object Model (DOM)

The DOM is an API that treats an HTML document as a tree structure where each
node is an object representing a part of the document.

Common DOM Methods

• [Link]('id'): Selects an element by unique ID.

• [Link]('.class'): Selects the first element matching a


CSS selector.

• [Link]: Gets or sets the HTML content.

• [Link]: Modifies CSS properties directly.

// Changing content of a div


let myDiv = [Link]('main');
[Link] = "

Welcome to JavaScript

";
[Link] = "yellow";

Unit 6: Event Handling

Events are interactions that occur in the browser, such as clicks, mouse movements,
or key presses.

AKTU JavaScript Study Guide (KCS-602) Page 4


Event Listeners

Modern approach using addEventListener allows multiple handlers for the same
event.

const btn = [Link]('#submitBtn');


[Link]('click', function(event) {
alert('Button was clicked!');
});

Unit 7: Objects & Prototype Inheritance

JavaScript is a prototype-based language. When we try to access a property of an


object, JS first looks at the object itself, then its prototype.

let person = {
name: "John",
greet: function() { [Link]("Hi, " + [Link]); }
};

let student = [Link](person);


[Link] = "Rahul";
[Link](); // Outputs: Hi, Rahul (Inherited from person)

Unit 8: Asynchronous JavaScript (AJAX, Promises)

Asynchronous programming allows the browser to perform tasks (like fetching data)
without freezing the UI.

Promises

A Promise is an object representing the eventual completion of an asynchronous


operation.

AKTU JavaScript Study Guide (KCS-602) Page 5


const myPromise = new Promise((resolve, reject) => {
let success = true;
if(success) resolve("Data Loaded");
else reject("Error Occurred");
});

[Link](res => [Link](res)).catch(err => [Link](err));

Async / Await

Introduced in ES8, async/await makes asynchronous code look synchronous and


easier to read.

Unit 9: ES6+ Features

• Destructuring: Easily extract values from arrays or objects.

• Template Literals: String interpolation using backticks (` `) and ${}.

• Spread/Rest Operator: ... for copying or merging.

Unit 10: Form Validation

Crucial for AKTU exams, form validation ensures user input is correct before being
sent to the server.

function validate() {
let x = [Link]["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}

AKTU JavaScript Study Guide (KCS-602) Page 6


Unit 11: Browser Object Model (BOM)

The BOM allows JavaScript to interact with the browser window. The window object is
the global object of BOM.

• [Link] / [Link]

• [Link]: Used to get/set current page URL.

• [Link]: Contains the browser history.

• [Link]: Stores data with no expiration date.

Unit 12: JSON (JavaScript Object Notation)

JSON is a lightweight format for storing and transporting data. It is often used when
data is sent from a server to a web page.

// JSON to Object
let obj = [Link]('{"name":"Rahul", "age":22}');

// Object to JSON
let str = [Link](obj);

Unit 13: Higher Order Functions

Functions that take other functions as arguments or return functions are called
Higher Order Functions (e.g., map(), filter(), reduce()).

const numbers = [1, 2, 3, 4];


const doubled = [Link](num => num * 2);
// Result: [2, 4, 6, 8]

AKTU JavaScript Study Guide (KCS-602) Page 7


Unit 14: Error Handling

Using try...catch...finally to handle runtime errors gracefully.

Unit 15: Revision Questions (AKTU Pattern)

1. Explain the difference between == and === with examples.

2. Describe the DOM tree structure.

3. What is an Arrow function? How is it different from a regular function?

4. Write a script to perform Email validation in a form.

5. Explain the life cycle of a Promise.

AKTU JavaScript Study Guide (KCS-602) Page 8

You might also like