FSD
FSD
FSD
Audio and Video Support: HTML5 introduced native support for embedding audio and video
content using the <audio> and <video> elements.
<audio controls>
<source src="audio.mp3" type="audio/mpeg"> Your browser does not support the audio element.
</audio>
<video controls width="320" height="240">
<source src="video.mp4" type="video/mp4">Your browser does not support the video element.
</video>
Canvas: The <canvas> element allows for dynamic, scriptable rendering of 2D graphics. It's
commonly used for games, data visualization, and interactive graphics.
<canvas id="myCanvas" width="400" height="200"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(50, 50, 100, 100);
</script>
Geolocation: HTML5 enables websites to access the user's geographical location through the
Geolocation API.
<button onclick="getLocation()">Get Location</button>
<p id="demo"></p>
<script>
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
document.getElementById('demo').innerHTML = 'Geolocation is not supported by
this browser.';
}
}
function showPosition(position) {
document.getElementById('demo').innerHTML = 'Latitude: ' + position.coords.latitude
+ '<br>Longitude: ' + position.coords.longitude;
}
</script>
Drag and Drop: HTML5 enables easy implementation of drag-and-drop functionality for
elements on a web page.
<div id="dragTarget" draggable="true">Drag me!</div>
<div id="dropTarget">Drop here!</div>
<script>
var dragTarget = document.getElementById('dragTarget');
var dropTarget = document.getElementById('dropTarget');
dragTarget.addEventListener('dragstart', function (event) {
event.dataTransfer.setData('text', event.target.id);
});
dropTarget.addEventListener('dragover', function (event) {
event.preventDefault();
});
(PPT Give you more understanding than PDF) The material for the PDF has been compiled from various sources such as books, tutorials
(offline and online), lecture notes, several resources available on Internet. The information contained in this PDF is for general information
and education purpose only. While we endeavor to keep the information up to date and correct, we make no representation of any kind
about the completeness and accuracy of the material. The information shared through this PDF material should be used for educational
purpose only.
(PPT Give you more understanding than PDF) The material for the PDF has been compiled from various sources such as books, tutorials
(offline and online), lecture notes, several resources available on Internet. The information contained in this PDF is for general information
and education purpose only. While we endeavor to keep the information up to date and correct, we make no representation of any kind
about the completeness and accuracy of the material. The information shared through this PDF material should be used for educational
purpose only.
2. Ng-controller: The ng-controller Directive in AngularJS is used to add the controller to the
application. It can be used to add methods, functions, and variables that can be called on some
event like a click, etc to perform a certain action. Example: This example illustrates the
implementation of the ng-controller directive in AngularJS.
<!DOCTYPE html>
<html>
<head> <title>AngularJS ng-controller Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="MyController">
<h1>{{ greeting }}</h1> <button ng-click="changeGreeting()">Change Greeting</button>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('MyController', function($scope) {
$scope.greeting = 'Hello, World!';
$scope.changeGreeting = function() {
$scope.greeting = 'New Greeting!';
}; });
</script>
</body></html>
(PPT Give you more understanding than PDF) The material for the PDF has been compiled from various sources such as books, tutorials
(offline and online), lecture notes, several resources available on Internet. The information contained in this PDF is for general information
and education purpose only. While we endeavor to keep the information up to date and correct, we make no representation of any kind
about the completeness and accuracy of the material. The information shared through this PDF material should be used for educational
purpose only.
Q.4) What is Java Scripts Object Literals? Explain example & syntax?
Object literals are one of the most commonly used data structures in JavaScript. They are used to
store collections of data, and can be used to represent complex data structures such as objects,
arrays, functions, and even regular expressions. Object literals are also used to store information
about a particular instance of an object, such as its state or behavior. Object literals are written in
the form of key-value pairs, where each key is a string and each value can be any valid JavaScript
data type.
For example, the following object literal stores information about a person:
script.js
const person = {
name: 'John Doe', age: 30, address: '123 Main Street'
};
Example:
const person = { In the example above, this refers to
firstName: "John", the person object. In this first Name means
lastName : "Doe", the first Name property of this. In this First
id : 5566, Name means the firstName property
fullName : function() { of person.
return this.firstName + " " + this.lastName;
}
};.
Q.7) Explain JavaScript split & substr with syntax & example?
The split() method splits (divides) a string into two or more substrings depending on a splitter
(or divider). The splitter can be a single character, another string, or a regular expression. After
splitting the string into multiple substrings, the split() method puts them in an array and returns it.
1. String split() method: The String.prototype.split() divides a string into an array of substrings:
split([separator, [,limit]]);
a. Separator : The separator determines where each split should occur in the original string. The
separator can be a string. Or it can be a regular expression. If you omit the separator or
the split() cannot find the separator in the string, the split() returns the entire string.
b. Limit : The limit is zero or positive integer that specifies the number of substrings.
The split() method will stop when the number of substrings equals to the limit. If the limit is zero,
the split() returns an empty array. If the limit is 1, the split() returns an array that contains the
string.
Let’s take some examples of using the split() method.
I. Splitting the strings into words example:
let str = 'JavaScript String split()';
let substrings = str.split(' ');
console.log(substrings);Code language: JavaScript (javascript)
Output:
["JavaScript", "String", "split()"]Code language:
JavaScript (javascript)
II. Returning a limited number of substrings example: The following example uses
the split() method to divide a string into substrings using the space separator. It also uses the
second parameter to limit the number of substrings to two:
let str = 'JavaScript String split()';
let substrings = str.split(' ',2);
console.log(substrings);
Code language: JavaScript (javascript)
Output:
["JavaScript", "String"]
Summary: Use the JavaScript String split() to divide a string into an array of substrings by a
separator. Use the second parameter (limit) to return a limited number of splits.
2. JavaScript substr(): The substr() method extracts a part of a string. The substr() method begins
at a specified position, and returns a specified number of characters. The substr() method does
not change the original string. To extract characters from the end of the string, use a negative start
position.
I. Extracting a substring from the beginning of the string example: The following example
uses the substring method to extract a substring starting from the beginning of the string:
let str = 'JavaScript Substring';
let substring = str.substring(0,10);
console.log(substring);
Output:
JavaScript
II. Extracting a substring to the end of the string example: The following example uses the
substring() to extract a substring from the index 11 to the end of the string:
let str = 'JavaScript Substring';
let substring = str.substring(11);
console.log(substring);
Output:
Substring
III. Extracting domain from the email example: The following example uses
the substring() with the indexOf() to extract the domain from the email:
let email = 'john.doe@gmail.com';
let domain = email.substring(email.indexOf('@') + 1); console.log(domain);
How it works: First, the indexOf() returns the position of the @ character, Then the substring
returns the domain that starts from the index of @ plus 1 to the end of the string.
Summary :The JavaScript substring() returns the substring from a string between the start and
end indexes.
(PPT Give you more understanding than PDF) The material for the PDF has been compiled from various sources such as books, tutorials
(offline and online), lecture notes, several resources available on Internet. The information contained in this PDF is for general information
and education purpose only. While we endeavor to keep the information up to date and correct, we make no representation of any kind
about the completeness and accuracy of the material. The information shared through this PDF material should be used for educational
purpose only.
Q.3) What Nodejs can perform? Write about command line interface?
Node.js can Perform:
o Node.js can generate dynamic page content
o Node.js can create, open, read, write, delete, and close files on the server
o Node.js can collect form data
o Node.js can add, delete, modify data in your database
Node.js File means:
o Node.js files contain tasks that will be executed on certain events
o A typical event is someone trying to access a port on the server
o Node.js files must be initiated on the server before having any effect
o Node.js files have extension ".js"
Command Line Interface: Node.js files must be initiated in the "Command Line Interface"
o Node.js process model increases the performance and scalability with a few caveats. Node.js is
not fit for an application which performs CPU-intensive operations like image processing or other
heavy computation work because it takes time to process a request and thereby blocks the single
thread.
o Contrary to the traditional web server model, NodeJS uses an event-driven, non-blocking I/O
model that makes it lightweight and efficient. The NodeJS process model can be explained with
three architectural features of NodeJS.
B. Connection string: A connection string is a string of text that contains the necessary information
to connect to a database server. It typically includes the following elements:
Hostname: The IP address or domain name of the database server.
C. Database operation: Once a connection to the database is established, Node.js applications can
perform various operations on the data. These operations can be broadly categorized into the
following types:
Creating: Inserting new data into the database.
Reading: Retrieving existing data from the database.
Updating: Modifying existing data in the database.
Deleting: Removing data from the database.
These operations are typically performed using the database driver's API, which provides methods
for each type of operation. For example, to create a new user in a MySQL database, you might
use the following code:
const mysql = require('mysql');
const connection = mysql.createConnection({
host: 'localhost',
port: 3306,
database: 'mydatabase',
user: 'root',
password: 'password'
});
connection.connect(err => {
if (err) throw err;
const sql = 'INSERT INTO users (username, email) VALUES (?, ?)';
const values = ['johndoe', 'johndoe@example.com'];
connection.query(sql, values, (err, result) => {
if (err) throw err;
console.log('User created successfully');
});
connection.end();
});
This code connects to a MySQL database, creates a new user record, and then closes the
connection.
(PPT Give you more understanding than PDF) The material for the PDF has been compiled from various sources such as books, tutorials
(offline and online), lecture notes, several resources available on Internet. The information contained in this PDF is for general information
and education purpose only. While we endeavor to keep the information up to date and correct, we make no representation of any kind
about the completeness and accuracy of the material. The information shared through this PDF material should be used for educational
purpose only.