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

JavaScript Tasks and Concepts

The document explains JavaScript objects, pop-up boxes, events, and event listeners, highlighting their definitions, syntax, and examples. It also outlines tasks for creating a web page about Telugu kings, building a museum form, designing a timeline, and creating a history quiz. Key features include the use of key-value pairs in objects, different types of pop-up boxes for user interaction, and the functionality of event listeners for handling events.

Uploaded by

mastanbisk038
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 views4 pages

JavaScript Tasks and Concepts

The document explains JavaScript objects, pop-up boxes, events, and event listeners, highlighting their definitions, syntax, and examples. It also outlines tasks for creating a web page about Telugu kings, building a museum form, designing a timeline, and creating a history quiz. Key features include the use of key-value pairs in objects, different types of pop-up boxes for user interaction, and the functionality of event listeners for handling events.

Uploaded by

mastanbisk038
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
You are on page 1/ 4

### JavaScript Objects

JavaScript objects are collections of key-value pairs. These are used to store multiple values in a

single variable. Objects can hold properties (key-value pairs) and methods (functions).

Key Features:

- Objects are defined using curly braces {}.

- Properties can store any data type, including other objects and arrays.

- Methods are functions defined inside an object.

Syntax:

let objectName = {

property1: value1,

property2: value2,

method1: function() {

// Method logic here

};

Example:

let teluguKing = {

name: "Sri Krishnadevaraya",

reign: "1509-1529",

empire: "Vijayanagara Empire",

introduce: function() {

console.log(`I am ${this.name}, ruler of the ${this.empire}`);

}
};

// Accessing properties

console.log(teluguKing.name); // Output: Sri Krishnadevaraya

// Calling methods

teluguKing.introduce(); // Output: I am Sri Krishnadevaraya, ruler of the Vijayanagara Empire

### Pop-up Boxes in JavaScript

JavaScript provides three types of pop-up boxes to interact with users:

1. Alert Box: Displays a message and an OK button.

2. Confirm Box: Displays a message with OK and Cancel buttons, returning true or false.

3. Prompt Box: Allows users to input a value and returns it.

Syntax and Examples:

Alert Box:

alert("Welcome to the Vijayanagara Empire!");

Confirm Box:

let decision = confirm("Do you wish to know about Sri Krishnadevaraya?");

if (decision) {

console.log("Great! Let's explore!");

} else {

console.log("Maybe next time!");


}

Prompt Box:

let visitorName = prompt("What is your name?");

console.log(`Hello, ${visitorName}! Welcome to Vijayanagara.`);

### Events in JavaScript

Events are actions or occurrences that happen in the browser, such as clicking a button, loading a

page, or hovering over an element.

Types of Events:

- Mouse Events: click, dblclick, mouseover, mouseout

- Keyboard Events: keydown, keypress, keyup

- Form Events: submit, change, focus, blur

- Window Events: load, resize, scroll

Example:

document.getElementById("greetButton").onclick = function() {

alert("Welcome to the kingdom of Vijayanagara!");

};

### Event Listeners in JavaScript

Event listeners are used to attach a function to a specific event. They provide a cleaner way to

handle events and support multiple handlers for a single event.

Syntax:
element.addEventListener(event, function, useCapture);

Example:

document.getElementById("infoButton").addEventListener("click", function() {

alert("This is information about the great Telugu kings.");

});

### JavaScript Tasks

1. Create a web page about Telugu kings using objects, events, and event listeners.

2. Build a form for a museum using prompt boxes and CSS styling.

3. Design a timeline for kings with interactive mouse events and toggling.

4. Create a history quiz with confirm boxes and dynamic event handling.

Clues:

- Task 1: "He is known as the Sun King of Telugu Literature."

- Task 2: "A form to welcome visitors to the ancient capital."

- Task 3: "A timeline where kings speak through mouse hovers."

- Task 4: "A quiz fit for a history enthusiast."

You might also like