Javascript one shot
Javascript one shot
Javascript
In one Shot
1
VIRTUAL CODE
Click to edit Master title style
Level 0
Introduction to JavaScript
2 2
VIRTUAL CODE
Click to
What is JavaScript:
edit Master title style
3 3
VIRTUAL CODE
Click to edit Master title style
Level 1
Va r i a b l e s & D a t a Ty p e s
4 4
VIRTUAL CODE
Click to edit
Variables : Master title style
20 30 40
a b c
6 6
VIRTUAL CODE
Click to editof
Declaration Master
Variables
title :style
• let a = 20;
• var a = 20;
• const a = 20;
7 7
VIRTUAL CODE
Click to
Rules foredit
choosing
MasterVariable’s
title stylenames :
8 8
VIRTUAL CODE
Click to edit
Primitive dataMaster
typestitle
& objects
style :
9 9
VIRTUAL CODE
Click to :edit Master title style
objects
values
keys
1010
VIRTUAL CODE
Click to practice
Level-1 edit Master
sheet
title style
1111
VIRTUAL CODE
Click to edit Master title style
Level 2
Operators & Conditional statements
1212
VIRTUAL CODE
Click to edit
Operators In Master
javascript
title style
Arithmetic operators
+ Addition
- Subtraction
* multiplication
** exponentiation
/ Division
% Modulus
++ Increment
-- Decrement
1313
VIRTUAL CODE
Click to edit
Operators In Master
javascript
title style
Assignment operators
= a=b
+= a=a+b
-= a=a-b
*= a=a*b
/= a=a/b
%= a=a%b
**= a=a**b
1414
VIRTUAL CODE
Click to edit
Operators In Master
javascript
title style
Comparison operators
== Equal to
!= Not equal to
=== Equal value and type
!== Not equal value or not
equal type
? Ternary operator
> Greater than
< Less than
>= Greater than or equal
to
<= Less than or equal to
1515
VIRTUAL CODE
Click to edit
Operators In Master
javascript
title style
logical operators
&& Logical and
|| Logical or
! Logical not
1616
VIRTUAL CODE
Click to editstatements:
Conditional Master title style
• if statement
• If-else statement
• If-else if statement
1717
VIRTUAL CODE
Click to operator
ternary edit Master title style
True False
1818
VIRTUAL CODE
Click to practice
Level-2 edit Master
sheet
title style
1919
VIRTUAL CODE
Click to edit Master title style
Level 3
Loops and Functions
2020
VIRTUAL CODE
Click to edit Master title style
Loops:
• Use to perform repeated actions.
Loops
2121
VIRTUAL CODE
Click
for Loop:
to editinitialization
Master title style
condition updation
• for loop
• for in loop
• for of loop
2222
VIRTUAL CODE
Click to
while Loop:
edit Master title style
do-while Loop:
2323
VIRTUAL CODE
Click to edit
Functions in Master
javascript
title: style
2424
VIRTUAL CODE
Click to editof
Declaration Master
function:
title style
2525
VIRTUAL CODE
Click to edit
Function calling:
Master title style
2626
VIRTUAL CODE
Click to practice
Level-3 edit Master
sheet
title style
2727
VIRTUAL CODE
Click to edit Master title style
Level 4
Strings
2828
VIRTUAL CODE
Click to:edit Master title style
Strings
• Template literals
name is variable
• Escape sequence characters
\n New line
\t tab 2929
VIRTUAL CODE
Click tomethod
Strings edit Master title style
Properties & methods
name.length
name.toLowerCase( )
name.toUpperCase( )
name.slice(a,b) or
name.slice(a)
name.replace(“abc”,”def”)
name1.concat(name2)
name.trim( )
3030
VIRTUAL CODE
Click to practice
Level-4 edit Master
sheet
title style
• Find the output:
3131
VIRTUAL CODE
Click to edit Master title style
Level 5
Arrays
3232
VIRTUAL CODE
Click to: edit Master title style
Arrays
• Arrays are variables which can hold more than one
value.
3333
VIRTUAL CODE
Click to edit
Methods of Arrays
Master: title style
Methods of Arrays
toString( ) Convert an array to a string of comma separated values
join( ) Joins all the arrays elements using a separator
pop( ) Removes last element from the array
push( ) Adds a new element at the end of the array
shift( ) Removes first element and returns it
unshift( ) Adds element to the beginning returns new array length
delete Array elements can be deleted using delete operator
Concat( ) Used to join arrays to the given array
Sort( ) It is used to sort an array alphabetically
splice( ) Splice can be used to add new items to an array
slice( ) Slices out a piece from an array , it creates a new array
reverse( ) Reverse the elements in source array
3434
VIRTUAL CODE
Click to through
looping edit Master
Arrays
title: style
• forEach loop:
• map( ) :
• filter( ) :
3535
VIRTUAL CODE
Click to through
looping edit Master
Arrays
title: style
• Reduce method:
• Array.from :
3636
VIRTUAL CODE
Click to practice
Level-5 edit Master
sheet
title style
• Create an array of numbers and take input from the
user to add numbers to the beginning of this array.
• Keep adding numbers to the array in 1 until 27 is added
to the array.
• Filter for even numbers from a given array
• Create an array of cube of given number.
• Use reduce to calculate factorial of a given number from
an array of first n natural numbers
3737
VIRTUAL CODE
Click to edit Master title style
Level 6
DOM :Document Object Model
3838
VIRTUAL CODE
Click to edit
Console object
Master
methods
title style
3939
VIRTUAL CODE
Click to edit Master
alert,prompt and confirm
title style
4040
VIRTUAL CODE
Click to edit
Window object,
Master
BOMtitle
& DOM
style
Window
4141
VIRTUAL CODE
Click to
BOM: Browser
edit Master
Objecttitle
Model
style
- The browser object model(BOM) represents additional
objects provided by the browser for working with
everything except document
- The functions alert/confirm/prompt are also a part of
BOM
4242
VIRTUAL CODE
Click to
DOM: Document
edit Master
Object
titleModel
style
- DOM represents the page content as HTML
- DOM tree refers to the HTML page where all the nodes
are object , there can be three main types of node in the
DOM Tree:
- Text node
- Element node
- Comment nodes
4343
VIRTUAL CODE
Click to edit
Walking the DOM
Master title style
Access the elements
element.firstChild First child element
element.lastChild last child element
element.childNodes All child nodes
element.parentNode Parent nodes
element.parentElement Parent elements
document.previousElementSibling Previous element
sibling
document.nextElementSibling next element sibling
document.firstElementChild First element
child
document.lastElementChild Last element
child
4444
VIRTUAL CODE
Click to edit
Searching theMaster
DOM title style
Searching the DOM
document.getElementById( ) Get a element by id
document.querySelectorAll( ) Return all the elements inside an
element matching the given CSS
selectors
document.querySelector( ) Return a element inside an element
matching the given CSS selectors
document.getElementsByTagName( ) Return elements with given tag
name
document.getElementsByClassName( ) Returns elements that have the
given CSS class
document.getElementsByName( ) Searches elements by the name
attribute
4545
VIRTUAL CODE
Click to edit Master
Matches,closest & contains
title style
methods
4646
VIRTUAL CODE
Click to practice
Level-6 edit Master
sheet
title style
• Write a program using prompt function to take input of
age as a value from the user and use alert to tell him if
he can derive , use confirm to ask the user if he wants
to see prompt again
• Change the background of the page to any other color
based on user’s input
• Create a nav bar and change the color of its first
element to brown.
• Write a javascript code to change background of all <li>
tags to purple
4747
VIRTUAL CODE
Click to edit Master title style
Level 7
Events & other DOM properties
4848
VIRTUAL CODE
Click to edit
Attribute Methods
Master title style
Access the elements
a.has Attribute(name) Method to check for
existence of an attribute
a.getAttribute(name) Method used to get the value
of an attribute
a.setAttribute(name,value) Method used to set the value
of an attribute
a.removeAttribute(name) Method to remove the
attribute from a
a.attributes Method to get the collection
of all atributes
data-x Attribute
4949
VIRTUAL CODE
Click to editand
innerHTML Master
outerHTML
title style
• The innerHTML property allows to get the HTML inside
the element as a string
• The outerHTML property contains the full HTML
innerHTML + the element itself
Insertion Methods
5050
Click to edit Master title style
Some insertion Method
name.append(box) Append at the end of node
name.prepend(box) Insert at the beginning of
node
name.before(box) Insert before node
name.after(box) Insert after node
5151
Click to edit
Insert Master
Adjacent title style
Html/text/element
“beforebegin” Insert HTML immediately
before element
“afterbegin” Insert HTML into element at
the beginning
“beforeend” Insert HTML into element at
the end
“afterend” insert HTML immediately
after element
5252
Click to edit Master title
className style
and classList
Name.classList.add(“class”) Add a class.
Name.classList.remove(“class”) Remove a class
Name.classList.toggle(“class) Add the class if does not exist,otherwise
removes it
Name.classList.contains(“class”) Checks for the given class,returns true/false
5353
VIRTUAL CODE
Click to editand
SetTimeout Master
SetInterval
title style
• SetTimeout allows us to run a function once after the interval of time
• Let timerID=setTimeout(function,<delay>,<arg1>,<arg2>)
• clearTimeout(timerID)
5454
VIRTUAL CODE
Click to edit
Browser Events
Master title style
• An event is a signal that something has
happened all the DOM nodes generates
such signal
5555
VIRTUAL CODE
Click to edit
Handling Events
Master title style
5656
VIRTUAL CODE
Click to practice
Level-7 edit Master
sheet
title style
• Write a program to change different background color
on body by clicking different buttons
• create a nightmode feature in your website
5757
VIRTUAL CODE
Click to editDigital
Project-1 Master Clock
title style
• Create a digital clock using setInterval and date object
in javascript with good UI using HTML & CSS
5858
VIRTUAL CODE
Click to edit Master title style
Level 8
Callbacks, promises,async & await
5959
VIRTUAL CODE
Click to edit Master
Synchronous & Asynchronous
title style actions
• Synchronous: means the code runs in a particular
sequence of instructions given in the program.
• Each instruction waits for the previous instruction to
complete its execution
6060
VIRTUAL CODE
Click to edit Master title style
Callbacks
• A callback is a function passed as an argument to
another function.
Callback Hell
• Nested callbacks stacked below one another forming a
pyramid structure.
• Pyramid Of Doom
• This style of programming becomes difficult to
understand & manage
6161
VIRTUAL CODE
Click to edit Master title style
Promises
• Promises is for “eventual” completion of task.it is an
object in js .
• It is a solution to callback hell.
6262
VIRTUAL CODE
Click to
Async - Await
edit Master title style
• Async function always returns a promise .
6363
VIRTUAL CODE
Click to
Fetch API
edit
( Application
Master titleProgramming
style Interface )
• The fetch API provides an interface for fetching
(sending/receiving) resources .
• It uses request and response objects
• The fetch() method is used to fetch a resource or data.
6464
VIRTUAL CODE
Click to
Fetch API
edit
( Application
Master titleProgramming
style Interface )
• The fetch API provides an interface for fetching
(sending/receiving) resources .
• It uses request and response objects
• The fetch() method is used to fetch a resource or data.
6565
VIRTUAL CODE
Click to editWeather
Project-2 Master title
app style
• Create a Weather app using api in javascript with good
UI using HTML & CSS
6666
VIRTUAL CODE
Click to edit Master title style
Thank You
67