HTML Injection:
HTML injection is a web security vulnerability that allows an attacker to inject malicious code into a website or web application. HTML injection can occur when user input is not properly validated or sanitized before being included in an HTML page. This can lead to the execution of arbitrary code, theft of sensitive data, or the redirection of users to malicious websites.
Clickjacking:
Clickjacking is a web security vulnerability that tricks a user into clicking on a button or link on a web page without their knowledge or consent. Clickjacking attacks typically involve overlaying an invisible or disguised element on top of a legitimate button or link. When the user clicks on the disguised element, they unknowingly trigger the action associated with the underlying button or link. Clickjacking attacks can be used to steal user credentials, install malware, or carry out other malicious actions.
5.> Explain Table Elements : Colspan/ Rowspan Attributes, border, cellspacing and cellpadding attributes,
To make a cell span over multiple columns, use the colspan attribute:
<table>
<tr>
<th colspan="2">Name</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>43</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>57</td>
</tr>
</table>
To make a cell span over multiple rows, use the rowspan attribute:
<table>
<tr>
<th>Name</th>
<td>Jill</td>
</tr>
<tr>
<th rowspan="2">Phone</th>
<td>555-1234</td>
</tr>
<tr>
<td>555-8745</td>
</tr>
</table>
Border Attribute:
The border attribute is used to add a border to a table or a cell. The value of this attribute specifies the width of the border in pixels. For example, if you set the border attribute to 1, a 1-pixel border will be added to the table or the cell.
Cellspacing and Cellpadding Attributes:
The cellspacing attribute specifies the amount of space between two cells in a table. It is used to create gaps between cells. The cellpadding attribute specifies the amount of space between the cell content and the cell border. It is used to create space between the cell content and the cell border.
<table border="1" cellpadding="10" cellspacing="0">
<tr>
<td rowspan="2">1</td>
<td colspan="2">2-3</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
Unit - 2
1.> explain arrow function in javascript
Arrow function is one of the features introduced in the ES6 version of JavaScript. The Arrow Functions in JavaScript helps us to create anonymous functions or methods i.e. functions without name. As they do not have any names, the arrow makes the syntax shorter.
let sum = (a, b) => {
let result = a + b;
return result;
}
let result1 = sum(5,7);
console.log(result1); // 12
2.> demonstrate the implementation of inheritance in javascript
To create a class inheritance, use the extends keyword.
A class created with a class inheritance inherits all the methods from another class:
The super() method refers to the parent class.
By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods.
class Car {
constructor(brand) {
this.carname = brand;
}
present() {
return 'I have a ' + this.carname;
}
}
class Model extends Car {
constructor(brand, mod) {
super(brand);
this.model = mod;
}
show() {
return this.present() + ', it is a ' + this.model;
}
}
let myCar = new Model("Ford", "Mustang");
document.getElementById("demo").innerHTML = myCar.show();
3.> Explain event handling in javascript
Event handlers typically have names that begin with on, for example, the event handler for the click event is onclick.
To assign an event handler to an event associated with an HTML element, you can use an HTML attribute with the name of the event handler.
When you assign JavaScript code as the value of the onclick attribute, you need to escape the HTML characters such as ampersand (&), double quotes ("), less than (<), etc., or you will get a syntax error.
<script>
function showAlert() {
alert('Clicked!');
}
</script>
<input type="button" value="Save" onclick="showAlert()">
4.> illustrate cloning and combining objects in javascript
In JavaScript, there are different ways to clone and combine objects, depending on the use case and desired outcome. Here are some examples:
Shallow cloning an object using the spread operator:
const obj1 = { a: 1, b: 2 };
const obj2 = { ...obj1 };
console.log(obj2); // { a: 1, b: 2 }
Deep cloning an object using JSON.parse() and JSON.stringify():
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = JSON.parse(JSON.stringify(obj1));
console.log(obj2); // { a: 1, b: { c: 2 } }
Combining objects using the spread operator:
const obj1 = { a: 1 };
const obj2 = { b: 2 };
const obj3 = { ...obj1, ...obj2 };
console.log(obj3); // { a: 1, b: 2 }
Combining objects using Object.assign():
const obj1 = { a: 1 };
const obj2 = { b: 2 };
const obj3 = Object.assign({}, obj1, obj2);
console.log(obj3); // { a: 1, b: 2 }
5. > Explain Browser and Document Object Model
The Browser Object Model (BOM) refers to the set of objects and methods that are exposed by the web browser itself. This includes things like the window object, which represents the current browser window or tab, and provides access to properties such as the current URL, the history of visited pages, and methods for displaying alerts or prompts to the user.
The Document Object Model (DOM) is a programming interface that allows scripts to dynamically access and update the content and structure of a web page. The DOM is a hierarchical tree-like structure that represents the HTML elements, attributes, and text content of a web page. Each element in the DOM is represented by a node object, which has properties such as childNodes, parentNode, attributes, and methods for manipulating the element's content, style, or event listeners.
Unit - 3
1.> what are the need and capabilities of node-js?
Node.js provides developers with a high-performance, cross-platform, and efficient environment to build scalable network applications with ease. Its rich package ecosystem and single programming language make it an excellent choice for developers looking to build complex applications quickly.
High-performance: Node.js is designed to handle a large number of simultaneous connections with high efficiency and low overhead. It uses an event-driven, non-blocking I/O model that makes it ideal for building scalable network applications.
Cross-platform: Node.js runs on various platforms such as Windows, macOS, and Linux. This makes it an ideal choice for developers who work across multiple platforms.
Huge package ecosystem: Node.js has a vast library of open-source modules and packages that can be easily installed and used in your project using the npm (Node Package Manager). This saves time and effort and makes it easier to build complex applications quickly.
Single programming language: Node.js uses JavaScript as its primary language, which means that developers can use the same language for both the front-end and back-end of their applications. This helps to simplify the development process and reduce the learning curve.
Real-time applications: Node.js is ideal for building real-time applications such as chat applications, gaming applications, and streaming services. This is due to its ability to handle multiple connections and events simultaneously.
2.> Illustrate the features of node-js
Features of Node.js is
Event-driven and non-blocking I/O model: Node.js uses an event-driven, non-blocking I/O model that allows it to handle multiple connections and events simultaneously. This makes it highly scalable and efficient, as it can handle a large number of requests without causing delays or blocking the server.
Cross-platform: Node.js runs on various platforms such as Windows, macOS, and Linux. This makes it an ideal choice for developers who work across multiple platforms.
Single-threaded: Node.js is single-threaded, but it can handle multiple concurrent requests using event loops and callbacks. This allows it to handle a large number of requests without consuming a lot of system resources.
NPM (Node Package Manager): Node.js has a vast library of open-source modules and packages that can be easily installed and used in your project using the npm (Node Package Manager). This saves time and effort and makes it easier to build complex applications quickly.
Asynchronous programming: Node.js supports asynchronous programming, which means that developers can write code that doesn't block the main thread and allows other tasks to be executed while waiting for a response from a database or network.
Real-time applications: Node.js is ideal for building real-time applications such as chat applications, gaming applications, and streaming services. This is due to its ability to handle multiple connections and events simultaneously.
Fast execution: Node.js uses the V8 JavaScript engine from Google Chrome, which is optimized for fast execution. This makes Node.js highly performant and efficient.