Web Development Long Term Notes
Web Development Long Term Notes
2. System Architecture:
From the user’s point of view, the web consists of a vast, worldwide
connection of documents or web pages. Each page may contain links to
other pages anywhere in the world¹. The pages can be retrieved and
viewed by using browsers¹.
3. Working of WWW:
The World Wide Web is based on several different technologies: Web
browsers, Hypertext Markup Language (HTML), and Hypertext Transfer
Protocol (HTTP)¹. A Web browser is used to access web pages¹.
Hyperlinked resources on the World Wide Web can be accessed using
software interfaces provided by Web browsers¹.
4. Features of WWW:
Webserver: which takes input request from the user and request client
for the response and displays the response in browser window
Paragraph
>html doesn’t allow the white spaces between the characters or words
so we need to use paragraph tag to display content in paragraph wise
List tag:
<ul type=”square”></ul>
<dl>
<dt></dt>
<dd></dd>
</dl>
Different tags:<hr>,<br>
Text formatting in HTML:
Ex:<h1><font color=”red”>triaright</font></h1>
Ex:<body bgcolor=”color”></body>
>highlighter: <mark></mark>
>subscript: <sub></sub>
>del: The <del> tag defines text that has been deleted from a
document.
online image :
offline image:
<img src=imgname.jpg/png/jpeg/>
ANCHOR TAG
The <a> tag defines a hyperlink, which is used to link from one page to
another.
HYPERLINK:
>The href attribute specifies the URL of the page the link goes to.
>If the href attribute is not present, the <a> tag will not be a hyperlink.
Attributes:
Href>hyperlink reference
Tables in HTML
HTML table.An HTML table consists of one <table> element and one or
more <tr>, <th>, and <td> elements.
Attributes:
2.cellpadding: the space between the cell context and its border.the
space inside the cell
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<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>
Colspan code:
<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>
Form in HTML:
The HTML <form> element is used to create an HTML form for user
input. The <form> element is a container for different types of input
elements, such as: text fields, checkboxes, radio buttons, submit
buttons, etc.
The <label> Element:
The <label> tag defines a label for many form elements. The <label>
element is useful for screen-reader users, because the screen-reader
will read out loud the label when the user focuses on the input element .
The <input> Element
The HTML <input> element is the most used form element. An <input>
element can be displayed in many ways, depending on the type
attribute.
Type=text/number/date/email/password/checkbox/radio/submit/
reset/time/color/url
Code:
<form>
<label>name</label>
<input type="text" placeholder="" required pattern="[a-zA-Z]{3,10}">
<br>
<label><font color=”red”>*</font>phone number</label>
<input type="number" placeholder="" required pattern="[0-9]{10}">
<br>
<label>Gender</label>
<input type="radio" name="gen">Male
<input type="radio" name="gen">Female <br>
<label>linked in profile</label>
<input type="url" required placeholder=""> <br>
<label>date</label>
<input type="date" placeholder=""><br>
<label>time</label>
<input type="time" placeholder=""><br>
<label>fav color</label>
<input type="color" required placeholder="" > <br>
<input type="submit" value="register">
<input type="reset" value="reset">
</form>
Multimedia
Onine video:
>select video click on share button
>select embded
>copy the iframe tag place in code
Offline video:
The <video> tag is used to embed video content in a document, such as
a movie clip or other video streams.
Code:
<video controls height=”” width=”” autoplay muted loop> //use auto
play and muted attribute to autoplay the video
<source src=”filename.mp4”>
</video>
Audio:
<audio controls>
<source src=””filename.mp3>
</audio>
Iframe tag:
The <iframe> tag specifies an inline frame.
An inline frame is used to embed another document within the current
HTML document.
CSS Backgrouds
1.background image: used if we want multiple color in background.
To apply multiple colors in background we need to use linear gradient
Ex code:
body{
background-image: linear-gradient(to left, red, yellow,green);
}
radial-gradient:
h1{
background-image: radial-gradient( red, yellow,green);
}
2.background-image:url(‘url/filename’);
To change background image of webpage.if the size of the image is less
it will repeat image.
body{
background-image: url('cricket.jpg');
}
3.background-repeat:
background-repeat: no-repeat/repeat-x/repeat-y/;
4.background-position:to cha
nge the position of background
background-repeat: no-repeat;
Background-position:center/top right/top left/bottom left/bottom
right;
5.background-size:to change size of background
Background-size:cover/px values
6.background-attachement:to fix or scroll the background
Background-attachment:fixed/scroll;
Text formatting:
1.to change the color of text: color
:value
2.to change the face(style) of the text font-family:value;
3.to change the size of text font-size:value;
4.to change weight of text font-weight:value;
5.to change the style of text font-style:value;
a:link{
color:blue;
}
a:hover{
color:brown;
}
a:visited{
color:chartreuse;
}
a:active{
color:deeppink;
}
position:fixed;
top:0px;
}
BOX MODEL:
The box model allows us to add a border around elements, and to
define space between elements. The total width and height of an
element should be calculated like this:
Margin-left:px
Margin-top:px;
Border:width style color;
Padding:px;
To get curved edges for borders
Border-radius:50px;
To apply border and css for tables
Table,tr,td,th{
Padding:20px;
Border:2px solid black;
Border-collapse:collapse //to remove excessive borders
}
Psuedo classes:used to define the styles for different states of HTML
elements.
Attributes
1.link:unvisited state of an anchor tag
2.hover:whenever user hovered with mouse
3.visited:we already visited the targeted web page
4.active:whenever user clicked on anchor tag
nth child:
The :nth-child(n) selector matches every element that is the nth child of
its parent. n can be a number, a keyword (odd or even), or a formula
(like an + b).
<style>
Table,td,th{
Border:2px,solid grey;
Padding:2px;
Border-collapse:collapse;
}
Tr.nth-child(even(or)odd){
Background-color:pink;
}
</style>
<body><table></table></body>
Pseudo properties:used to define styles for special parts of an element
Use(::) to implement pseudo properties.
1.first-letter
2.first-line
3.before-to apply content before code for “n” no.of tags
4.after:
5.selection:
<style>
P::first-letter{
Color:blue;
Text-transform:uppercase;
Font-family:chiller;
}
P::first-line{
Color:blue;
Text-transform:uppercase;
Font-family:chiller;
}
H1::before{
Content:’*’;
}
H1::after{
Content:’*’;
}
P::selection{
Background-color:red;
Color:black;
}
</style>
Display:we can define an HTML element how it can be
displayed on the screen.there are 3 different ways to use this display
properties
Flexbox
Flex box is used to design responsive layout without using positons and
float elements We need a flex container to design the layout We can
create flex container by using display:flex; property
1.Flex-direction:
to set directions for child elements in flexbox
Flex-direction:row/row-reverse/column/column-reverse
2.Justify-content=>to set alignment
Justify-content:start/center/end/space-between/space-around
3. flext-wrap=>to arrange all the elements with in the specified
size
Flex-wrap:wrap/no-wrap
JAVA SCRIPT
Variables
● Variables are Containers used for Storing Data.
● In JavaScript, a variable is like a container / box where you can store
different types of data, such as numbers, text, or even functions. You
can then use the name of the box (the variable) to access or change the
data stored inside.
Two types of variables: 1.local variable 2.global variable
1.local variable: A variable which is declared with in the block(a
function, a method, a class) is called local variable. We can use key
word called ‘let’.
2.global variable:A variable which is declared outside of the block. We
can use a key word called ‘var’.
3.const: This is used to declare variables that should not change once
they're assigned a value.
Data types
It specifies the type of data that we are working in variables. Java script
supports all types of data like number, float, Boolean, char, string, date,
object.
1.String: A string is a series of characters, like a word or a sentence. You
can use single or double quotes to create a string.
For example:
Let name=”triaright”;
2.number: The number data type can hold both integer and floating-
point numbers. There's a small difference between integers and
floating-point numbers in JavaScript.
For example:
Let x=10;
3.bigInt: BigInt is a special numeric type that can work with arbitrarily
large integers.
For example:
var x=BigInt(8**55)
document.write(x);
4.Boolean: Boolean represents a logical entity and can have two values:
true or false. It's often used in conditional statements.
For example:
<script>
let x = 5;
let y = 5;
let z = 6;
document.getElementById("demo").innerHTML =
(x == y) + "<br>" + (x == z);
</script>
5.undefined: A variable that has not been assigned a value is
undefined.
For example
let testVar;
console.log(testVar);
6.null: This is a special value that represents "nothing", "empty" or
"value unknown".
For example
Let val=””;
7.object: Objects are used to store keyed collections of various data
and more complex entities¹. Objects in
JavaScript can be thought of as a collection of properties¹. For example:
```javascript
let student = {
Id:123,
firstName: 'John',
lastName: 'Doe',
age: 20
};
Operators
JavaScript operators are symbols that perform operations on variables
and values. They allow you to manipulate and perform calculations on
data. Here's an overview of some common JavaScript operators:
Arithmetic Operators: Arithmetic operators in JavaScript are symbols or
keywords that perform mathematical operations on variables or values.
These operations include addition, subtraction, multiplication, division,
and modulus.
● Addition +
● Subtraction -
● Multiplication *(asterisk)
● Division /
● Modulus % (returns the remainder of a division)
● Increment ++
● Decrement –¬
Code:
let a = 10;
let b = 3;
let sum = a + b; // 13
let difference = a - b; // 7
let product = a * b; // 30
let quotient = a / b; // 3.333...
let remainder = a % b; // 1
let x = 5;
x++;
document.write(x + "<br>")
let y=6;
y--;
document.write(y);
Assignment Operators:
Assignment operators in Java Script, are symbols used to assign values
to variables. They combine the act of assigning a value to a variable
with an arithmetic operation.
● Assignment =
● Add and assign +=
● Subtract and assign -=
● Multiply and assign *=
● Divide and assign /=
● Modulus and assign %=
● Exponent and assign **=
Operator Example Same As
= x=y x=y
+= x += y x=x+y
-= x -= y x=x-y
*= x *= y x=x*y
/= x /= y x=x/y
%= x %= y x=x%y
**= x **= y x = x ** y
Logical Operators:
Logical operators in JavaScript are used to perform logical operations
on Boolean values. These operators allow you to combine or
manipulate Boolean values to make more complex decisions in your
code.
● AND &&
● OR ||
● NOT !
Code:
let x = true;
let y = false;
console.log(x && y); // false (AND)
console.log(x || y); // true (OR)
console.log(!x); // false (NOT)
Conditional Statements
If Statement:
The if statement is used to specify a block of code to be executed if a
specified condition is true
Syntax :
if (condition) {
// block of code to be executed if the condition is true
}
Code:
let num = 20;
if (num % 2 === 0) {
console.log("Given number is even number.");
}
If-Else Statement:
The if-else statement is used to specify a block of code to be executed if
a condition is true, and
another block of code to be executed if the same condition is false.
Syntax:
if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
}
Code:
let age = 25;
if (age >= 18) {
console.log("You are eligible for driving licence");
} else {
console.log("You are not eligible for driving licence");
}
Else If Statement:
The else if statement is used to specify a new condition to test if the
first condition is false.
Syntax:
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2
is true
} else {
// block of code to be executed if the condition1 is false and condition2
is false
}
Code:
let temperature = 28;
if (temperature > 30) {
console.log("It's hot outside");
} else if (temperature > 20) {
console.log("It's warm outside");
} else {
console.log("It's cool outside");
}
Switch Statement:
The switch statement is used to select one of many blocks of code to be
executed. It’s often used when you want to select one of many code
blocks to be executed.
Syntax:
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
} code:
let day;
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
document.getElementById("demo").innerHTML = "Today is " + day;
Javascript Loops
For Loop:
A for loop is a control structure used to repeat a block of code a fixed
number of times1. It’s defined with three expressions: initialization,
condition, and increment.
JavaScript
for (let i = 0; i < 5; i++) {
console.log(i); // This will print numbers 0 through 4
}
In the example above, i is initialized to 0, the loop continues as long as i
is less than 5, and i is incremented by 1 after each loop iteration.
While Loop:
A while loop is a control structure that executes a block of code as long
as a specified condition is true.
JavaScript
let i = 0;
while (i < 5) {
console.log(i); // This will print numbers 0 through 4
i++;
}
In the example above, the loop will continue to run as long as i is less
than 5
i is incremented by 1 after each loop iteration.
1.Java script program reverse of a number using while loop
var num=400, rem, rev=0
while(num!=0){
rem=num%10;
rev=rev*10+rem;
num=parseInt(num/10);
}
document.write("reverse of 123 is" + rev);
2.Java script program to check weather palindrome or not
function isPalindrome(str) {
let rev = "";
for (let i = str.length - 1; i >= 0; i--) {
rev += str[i];
}
if (rev == str) {
return true
} else {
return false;
}
}
console.log(isPalindrome(str1));
console.log(isPalindrome(str2));
console.log(isPalindrome(str3));
3.Java script program to print reverse of string.
// Function to reverse string
function reverseString(str) {
let strRev = "";
for (let i = str.length - 1; i >= 0; i--) {
strRev += str[i];
}
console.log(strRev);
}
// Function call
reverseString("JavaScript");
reverseString("TypeScript");
Do-While Loop:
A do-while loop is similar to a while loop, but the block of code is
executed at least once before the condition is checked.
JavaScript
let i = 0;
do {
console.log(i); // This will print numbers 0 through 4
i++;
} while (i < 5);
In the example above, the loop will first print 0, and then it will check if
i is less than 5.
For-In Loop:
The for-in loop is used to loop through the properties of an object1.
JavaScript
Let person = {firstName:"John", lastName:"Doe", age:25};
for (let key in person) {
console.log(key + ": " + person[key]);
}
In the example above, the loop will log each property and its value of
the person object
For-Of Loop:
The for-of loop is used to loop through the values of an iterable object,
like an array.
JavaScript
let colors = ['red', 'green', 'blue'];
for (let color of colors) {
console.log(color);
}
In the example above, the loop will log each color in the colors array.
Remember, loops are a powerful feature that let you repeat a block of
code until a certain condition is met. They’re extremely useful for tasks
that require the same code to be executed multiple times.
Javascript Functions
What are Functions?
A function in JavaScript is a block of reusable code designed to perform
a specific task1. You can think of a function as a sub-program within the
main program2. A function consists of a set of statements but executes
as a single unit2.
1.simple function
1.Function sample(){
Document.write(“hello world”);
}
Sample()
3.Arrow Functions:
Arrow functions provide a concise syntax to write functions in
JavaScript. They are especially useful when you want to write an
anonymous function in a single line, or if you are writing a lot of nested
functions. Here’s an example:
JavaScript
const add = (a, b) => a + b;
console.log(add(5, 3)); // Outputs: 8
4.Anonymous Functions:
Anonymous functions are functions that are declared without any
named identifier to refer to it. As such, an anonymous function is
usually not accessible after its initial creation. Here’s an example:
JavaScript
let x = function (a, b) {
return a * b;
};
console.log(x(4, 3)); // Outputs: 12
5.For each:for each is used to apply function for every element of an
array by iterating them.
var arr=[10,11,12,13,14,15];
arr.forEach((i)=>{if(i%2==0){document.write(i+"<br>")}});
7.filter:filter m
ethod is used to create new array from the given array consisting of
those elements which satisfied with a condition
var arr=[1,2,3,4,5,6];
var newarr=arr.filter((item)=>{return item%2==0})
document.write(newarr);
DOM Selection:
To manipulate the DOM, you first need to select the element you
want to work with. Here are some common ways to select elements:
1.getElementById:
This method gets the element with the specified ID.
example 1:
<body>
<p id="mypara">new era of learning</p>
<p id="demo"></p>
<script>
const element=document.getElementById("mypara");
document.getElementById("demo").innerHTML="the text from first
para is:: " + element.innerHTML;
</script>
</body>
example 2
<body>
<h1 id="demo">DOM Manipulations</h1>
<button onclick="changecolor()">click me</button>
<script>
function changecolor(){
var res=document.getElementById("demo").style.color="red";;
}
</script>
</body>
2.getElementsByClassName: This method gets all elements with the
specified class name1.
example 1:
<body>
<p>Triaright</p>
<p class="demo">finding elements by tag name</p>
<p class="demo">dom manipulations</p>
<p id="myid"></p>
<script>
const element=document.getElementsByClassName("demo");
document.getElementById("myid").innerHTML="the text in first
para: " + element[1].innerHTML;
</script>
</body>
example 2:
<body>
<h2 class="demo">hello world</h2>
<p class="demo">Triaright new era of learning</p>
<h1 >DOM Manipulations</h1>
<button onclick="changecolor()">click me</button>
<script>
function changecolor(){
var res=document.getElementsByClassName("demo");
res[0].style.color="pink";
res[1].style.color="yellow";
}
</script>
</body>
3.getElementsByTagName:
This method gets all elements with the specified tag name1.
example 1:
<body>
<p>finding elements by tag name</p>
<p>dom manipulations</p>
<p id="demo"></p>
<script>
const element=document.getElementsByTagName("p");
document.getElementById("demo").innerHTML="the text in first
para: " + element[0].innerHTML;
</script>
</body>
example 2:
<body>
<h1>hello world</h1>
<h1>DOM Manipulations</h1>
<button onclick="changecolor()">click me</button>
<script>
function changecolor(){
var res=document.getElementsByTagName("h1");
res[0].style.color="red";
res[1].style.color="blue";
}
</script>
4.querySelectorAll:
This method gets all elements that match a specified CSS selector1.
<body>
<p>Triaright</p>
<p class="demo">finding elements by tag name</p>
<p class="demo">dom manipulations</p>
<p id="myid"></p>
<script>
const element=document.querySelectorAll("p.demo");
document.getElementById("myid").innerHTML="the text in first
para: " + element[0].innerHTML;
</script>
</body>
DOM Manipulation:
Once you’ve selected an element, you can manipulate it in various
ways. Here are some common manipulations:
Changing Content:
You can change the content of an element using the textContent or
innerHTML property1.
JavaScript
let titleElement = document.getElementById('title');
titleElement.textContent = 'New Title'; // Changes the text content of
the element with id 'title'
code:
<p id="demo" onclick="myFunction()">Click me to change my textual
content.</p>
<script>
function myFunction() {
document.getElementById("demo").textContent = "I have changed!";
}
</script>
Changing Attributes:
You can change the attributes of an element using the setAttribute
method1.
JavaScript
let titleElement = document.getElementById('title');
titleElement.setAttribute('class', 'highlight'); // Changes the class of the
element with id 'title' to 'highlight'
code:
<style>
.democlass {
color: red;
}
</style>
<body>
<h1 id="myH1">The Element Object</h1>
<p>Click "Add Class" to add a class attribute to the h1 element:</p>
<button onclick="myFunction()">Add Class</button>
<script>
function myFunction() {
document.getElementById("myH1").setAttribute("class",
"democlass");
}
</script>
Changing Styles: You can change the CSS styles of an element using the
style property.
JavaScript
let titleElement = document.getElementById('title');
titleElement.style.color = 'blue'; // Changes the color of the text in the
element with id 'title' to blue
Code:
<h1 id="ramya">event handling</h1>
<button onclick="change()">click</button>
<script>
function change()
{
document.getElementById("ramya").style.color="red"; onclick
code
}
</script>
function leaveimg(bs) {
bs.style.height = "32px";
bs.style.width = "32px";
}
</script>
</body>
5.onmouseup
6.onmousedown
Used to call a function whenever mouse right click is pressed and
coming back to its original position is called onmouseup and down
Code:
<body>
<h1>mouse up down events</h1>
<p id="myphara" onmousedown="mousedown()"
onmouseup="mouseup()">Lorem ipsum</p>
<script>
function mousedown(){
document.getElementById("myphara").style.color="red";
}
function mouseup(){
document.getElementById("myphara").style.color="blue";
}
</script>
</body>
7.onload: The onload event occurs when an object has been loaded.
Code:
<body onload="myFunction()">
<h1>HTML DOM Events</h1>
<h2>The onload Event</h2>
<script>
function myFunction() {
alert("Page is loaded");
}
</script>
</body>
8.ononline: Call a function when the browser starts to work online
9.onoffline: Call a function when the browser starts to work offline
Used to call a function when the new connection is lost and when
connection is back we use on online
Code:
<body ononline="onFunction()" onoffline="offFunction()">
<h1 id="myh1"></h1>
<script>
function onFunction() {
document.getElementById("myh1").innerHTML = "login";
document.getElementById("myh1").style.color="green"
}
function offFunction() {
document.getElementById("myh1").innerHTML = "connection lost";
document.getElementById("myh1").style.color="red";
}
</script>
</body>
element.addEventListener('click',(evt)=>{
console.log("button 4 was clicked");
})
element.removeEventListener("click",x);
</script>
1. Creating an Element
In JavaScript, you can create a new element using the
document.createElement() method.
This method creates an HTML element specified by a tag name. Here's
an example of creating a new paragraph (``) element:
Code:
const para = document.createElement("p"); //output in console
In this example, `para` is now an object representing a element.
Code:
para.innerText = "This is a paragraph"; //output in console
Now, para represents a element with the text "This is a paragraph"
inside.
Local Storage
Sure, let's break down the concept of Local Storage in JavaScript into
several steps, each with a detailed explanation and a full-fledged
example.
What is Local Storage?
Local Storage is a property that allows JavaScript sites and apps to save
key-value pairs in a web browser with no expiration date. This means
the data stored persists even after the user closes the browser or
restarts the computer. It's part of the Web Storage API and is used for
storing and retrieving data.
1.Setting Items in Local Storage
You can add data to Local Storage using the `setItem()` method. This
method takes two parameters: the key and the value
Code:
localStorage.setItem('name', 'John Doe'); //console
In this example, we're storing the string 'John Doe' under the key
'name'.
2.Getting Items from Local Storage
You can retrieve data from Local Storage using the `getItem()` method.
This method takes one parameter: the key of the data you want to
retrieve.
Here's an example:
Code:
const name = localStorage.getItem('name');
console.log(name); // Outputs: John Doe
In this example, we're retrieving the data stored under the key 'name'
and logging it to the
console.
3.Removing Items from Local Storage
You can remove data from Local Storage using the `removeItem()`
method. This method takesone parameter: the key of the data you
want to remove.
Here's an example:
Code:
localStorage.removeItem('name'); //console
In this example, we're removing the data stored under the key 'name
4.Clearing Local Storage
You can clear all data from Local Storage using the `clear()` method.
Here's an example:
Code:
localStorage.clear(); //console
This will remove all data stored in Local Storage.
Enumerating Properties:
There are several ways to list/traverse object properties in JavaScript.
One common way is using
for...in loops2.
Here’s an example of enumerating properties:
Deleting Properties:
You can remove a non-inherited property from an object using the
delete operator
delete person.age;
console.log(person);
THIS Keyword:
This keyword is used to refer the current object
let laptop2={
brand:'hp',
price:30000,
ram:16,
cpu:'i7',
greet:function(){
console.log(laptop1.cpu);
}
}
let laptop1={
brand:'hp',
price:30000,
ram:16,
cpu:'i9',
greet:function(){
console.log(this.cpu);
}
}
laptop2.greet()
Constructor Functions
In JavaScript, a constructor function is used to create objects. A
constructor function is a special kind of function used to create and
instantiate objects, especially when multiple objects of the same kind
need to be created. A constructor defines the object properties and
methods.
Code:
function Mobile(mobilename,mobileprice,mobilecam)
{
this.mobilename=mobilename;
this.mobileprice=mobileprice;
this.mobilecam=mobilecam;
}
var m1=new Mobile("oneplus", 42000,"50mp");
var m2=new Mobile("redmi note 5",12000,"40px");
console.log(m1)
Iterating every property:
function Mobile(mobilename,mobileprice,mobilecam)
{
this.mobilename=mobilename;
this.mobileprice=mobileprice;
this.mobilecam=mobilecam;
}
var m1=new Mobile("oneplus", 42000,"50mp");
var m2=new Mobile("redmi note 5",12000,"40px");
var m3=new Mobile("redmi 5A", 5000,"30mp");
var m4=new Mobile("oppo 5A",13000,"40px");
var store=[m1,m2,m3,m4] //storing objects in array
for(x of store) // x is an object
{
for(dummy in x) //dummy is the key of object x and iterating keys of
object
{
document.write(dummy+":"+x[dummy]+"<br>")
}
}
<p id="demo"></p>
<script>
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
document.getElementById("demo").innerHTML =
myCar1.name + " " + myCar1.year;
</script>
Inheritence
Process of acquiring all functionalities of parent class from child class
<p>Use the "extends" keyword to inherit all methods from another
class.</p>
<p>Use the "super" method to call the parent's constructor
function.</p>
<p id="demo"></p>
<script>
class Car {
constructor(brand) {
this.carname = brand;
}
present() {
return 'I have a ' + this.carname;
}
}
CallBacks
A callback in JavaScript is a function that is passed as an argument to
another function and is executed after the main function has finished
its execution. The main function is called with a callback function as its
argument, and when the main function is finished, it calls the callback
function to provide a result.
Example1:
Function hello(callback)
{
Console.log(“hello is printed”);
Callback()
}
Function leave()
{
Console.log(“leave is printed”);
}
Hello(leave);
Example2:
function myDisplayer(some) {
console.log(some);
}
function myCalculator(num1, num2, myCallback) {
let sum = num1 + num2;
myCallback(sum);
}
myCalculator(5, 5, myDisplayer);
What is asynchronous :
Asynchronous operations are operations that take a significant amount
of time to complete.
What is a Promise?
A Promise in JavaScript is an object that represents the eventual
completion (or failure) of an asynchronous operation and its resulting
value. It’s a way to handle asynchronous operations without blocking
the rest of your code
Promise States
A Promise can be in one of three states:
Pending: The Promise is still working and hasn't been fulfilled or
rejected yet.
Fulfilled: The operation completed successfully.
Rejected: The operation failed.
Example code:
let mypromise=new Promise(function(resolve,reject){
let x=0;
if(x==0){
resolve("ok")
}
else{
reject("error");
}
})
Here x has 2 different states fullfill and reject. To handle those states
we need to use following methods then(), catch(), finally().
Then(): used to handle the promise when it is success or resolved
Catche():used to handle the promise when it is rejected.
Finally():used to execute the block of code with irrespective of result.
Code:
mypromise.then(
function(value) { console.log(value); }, // Success
);
mypromise.catch(
function(error) { console.log(error); },
);
mypromise.finally(
function(){console.log("promise completed")}
)
Timing functions:
Timing function in js used to execute a function in specific time intervals
or delay the execution of a function time intervals or delay the
execution of a function for specific time.
1.setTimeOut:used to delay the execution of a fun for specific time.
Syntax: setTimeOut(fun,millisecond)
2.setInterval:used to execute a fun at specific time intervals.
Syntax: setInerval(fun(){funname()},milliseconds)
Async Keyword
The async keyword can be placed before a function. This means the
function will always return a Promise. If the function returns a value
that is not a Promise, JavaScript automatically wraps it in a resolved
Promise.
Await Keyword
The await keyword can only be used inside an async function. It makes
the function pause and wait for the Promise to resolve or reject, then
resumes the execution and returns the resolved value.
Here’s an example:
Code:
async function myFunction() {
let promise = new Promise((resolve, reject) => {
setTimeout(() => resolve("done!"), 5000)
});
let result = await promise; // wait until the promise resolves
alert(result); // "done!"
}
myFunction();
Code:
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then((res)=>res.json())
.then((data)=>{
console.table(data)
})
Fluid Layouts:
With a fluid layout, you can create web pages that adapt to the current
viewport width and height². Common practice includes using the `max-
width` property instead of giving a fixed width to an element². Also,
using percentage (`%`), viewport height (`vh`), or viewport width (`vw`)
helps improve adaptability that is not possible with pixels (`px`).
Responsive Units:
As you move to more advanced CSS, you’ll often see the use of `rem`
and `em` units for length instead of `px` units². This is because the
`rem` unit makes it super easy to scale the entire layout.
Flexible Images
Images are a prime concern while designing even the most basic layout.
You always have to take care to size them properly so that they fit the
design. Also, by default, they don’t scale with changes in the viewport.
So, you should use `%` for the dimensions of your images, along with
the `max-width` property.
Media Queries:
You can bring responsive sites to life by using media queries. Fluid grids
are good to start with, but you’ll find that there are a few points where
the layout starts to break down. Adding breakpoints for these viewport
widths tunes the layout for different devices.
You can add a breakpoint where certain parts of the design will behave
differently on each side of the breakpoint¹. For instance, when the
screen (browser window) gets smaller than 768px, each column should
have a width of 100%¹:
```css
@media only screen and (max-width: 768px) {
/* For mobile phones: */
[class*="col-"] {
width: 100%;
}
}
Mobile First
Mobile First means designing for mobile before designing for desktop
or any other device¹. This will make the page display faster on smaller
devices¹. This means that we must make some changes in our CSS¹:
css
/* For mobile phones: */
[class*="col-"] {
width: 100%;
}
@media only screen and (min-width: 768px) {
/* For desktop: */
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
}
```
Multiple Breakpoints
You can add as many breakpoints as you like¹. For instance, you can add
one more media query (at 600px), and a set of new classes for devices
larger than 600px (but smaller than 768px)¹:
```css
@media only screen and (min-width: 600px) {
/* For tablets: */
.col-s-1 {width: 8.33%;}
.col-s-2 {width: 16.66%;}
.col-s-3 {width: 25%;}
.col-s-4 {width: 33.33%;}
.col-s-5 {width: 41.66%;}
.col-s-6 {width: 50%;}
.col-s-7 {width: 58.33%;}
.col-s-8 {width: 66.66%;}
.col-s-9 {width: 75%;}
.col-s-10 {width: 83.33%;}
.col-s-11 {width: 91.
20.Introduction to the Bootstrap Framework and Its Grid System.
Grid System:
The grid system is a key feature of Bootstrap. It's a flexible, mobile-first
layout system built with flexbox that's fully responsive¹. It's based on a
12-column layout, which can be customized to suit the needs of the
website³⁴.
Rows:
Rows are wrappers for columns. Each column has horizontal padding
(called a gutter) for controlling the space between them. This padding is
then counteracted on the rows with negative margins¹.
Columns:
In a grid layout, content must be placed within columns and only
columns may be immediate children of rows. Thanks to flexbox, grid
columns without a specified width will automatically layout as equal
width columns¹.
Here's an example of how to use the grid system:
html
<div class="container">
<div class="row">
<div class="col-sm"> One of three columns </div>
<div class="col-sm"> One of three columns </div>
<div class="col-sm"> One of three columns </div>
</div>
</div>
In this example, three equal-width columns are created on small,
medium, large, and extra-large devices using predefined grid classes¹.
To make the grid responsive, there are five grid breakpoints, one for
each responsive breakpoint: all breakpoints (extra small), small,
medium, large, and extra large¹.
Frame work:frame work is set of advaced features which is developed
by using core language
BOOT STRAP:
Frame work:frame work is set of advaced features which is developed
by using core language
BOOT STRAP:
Boot strap is the most popular HTML CSS and JS framework for
developing responsive mobile first projects on web
Boot strap overview:
>includes HTML CSS based design templates for forms,buttons tables
navigation images carousels and many others
>user increasingly accessing website from a verity of devices
media queries:
media queries used to responsive website with CSS here we can apply
some styles based on the user screen size
syntax:
@media(min-width:500px){
//css style customized for desktop
}
Grid system:
>writing meta tag to read the device width
>importing BS to our page
cdnjs>search for bootstrap>select link
bootstrap.min.css,bootstrap.bundle.min.js
Grid system:
>writing meta tag to read the device width
>importing BS to our page
images:
img-fluid/img-thumbnail/img-rounded/img-circle
buttons:
btn btn-success/btn
btn-primary/danger/info/warning/white/secondary
navigation bar code in BS
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<a href="" clas="navbar-brand"></a>
<div class="container-fluid">
<div class="col-md-5">
<button class="navbar-toggler" data-bs-toggle="collapse" data-
bs-target="#mynav">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="mynav">
<ul class="navbar-nav">
<li class="nav-item"><a href="sample.html" class="active nav-
link">Sample</a></li>
<li class="nav-item"><a href="home.html" class="nav-
link">home</a></li>
<li class="nav-item"><a href="about.html" class="nav-
link">about</a></li>
<li class="nav-item"><a href="contact.html" class="nav-
link">contact</a></li>
</ul>
</div>
</div>
</nav>
CAROUSEL CODE:
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="carousel slide" data-bs-ride="carousel" id="mycar">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="cricket.jpg" class="img-fluid">
</div>
<div class="carousel-item">
<img src="tree.jpg" class="img-fluid" >
</div>
<div class="carousel-item">
<img src="tree.jpg" class="img-fluid">
</div>
<div clas="carousel-item">
<img src="image.jpg" class="img-fluid">
</div>
</div>
<a href="" data-bs-target="#mycar" class="carousel-control-
prev" data-bs-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a href="" data-bs-target="#mycar" class="carousel-control-
next" data-bs-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
</div>
CARDS IN BOOTSTRAP
<div class="col-md-3">
<div class="card">
<img src="ambedkar.jpg" class="card-img-top">
<div class="card-body">
<h1>Ambedker</h1>
<p>Bhimrao Ramji Ambedkar was an Indian jurist, economist,
social reformer and political leader who headed the committee drafting
the Constitution of India ...</p>
<div class="card-footer">
<button class="btn btn-info">click me</button>
</div>
</div>
</div>
</div>
FORMS IN BOOTSTRAP:
<div class="container-fluid">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="form-group">
<label for="" class="form-label">Enter user name</label>
<input type="text" class="form-control">
</div>
<div class="form-group">
<label for="" class="form-label">enter password</label>
<input type="password" class="form-control">
</div>
<div class="form-group">
<label for="" class="form-label">enter mobile number</label>
<input type="number" class="form-control">
</div>
</div>
</div>
</div>
https://meet.jit.si/SuperiorConferencesApproachAnnually
https://meet.jit.si/LatterAgentsHuntLittle