SlideShare a Scribd company logo
Learn JavaScript From Scratch
Learn JavaScript From
Scratch
Mohd Manzoor Ahmed
(Microsoft Certified Trainer | 15+yrs Exp)
What Are We Going To Learn?
● Introduction To JavaScript
● Introduction To Visual Studio
● Modes Of Execution
● Data Types In JavaScript
● Conditional Statements
● UnConditional Statements
● Iterative or Loop
● Types Of Variables
● Events
● OOPs Through JavaScript
● Object
● Class
● Properties
● Methods
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Why JavaScript?
● We need responsive HTML pages.
○ React to events.
○ Read and write HTML elements.
○ Validate data.
○ Detect the visitor's browser.
○ Lot more these days....
What is JavaScript?
● JavaScript is a scripting and lightweight programming language.
● It is an interpreted language and requires a browser to run it.
● Everyone can use JavaScript without purchasing any license.
● It is usually embedded directly into HTML pages in script tag inside head tag.
● You can use any text editor to write javascript including HTML
○ <head>
○ <script type=”text/javascript”>
Display Hello World
● Mostly used methods to display any content at runtime on web page are
○ document.write()
○ console.log()
○ window.alert()
Demo
For “Hello World”
What is JavaScript?
● But these days it is being written in separate file and it’s extension is .js say
myScript.js
● It is being referred in the web pages using script tag at the bottom of the page, i.e.,
after body tag.
○ <html>
○ <head>
○ </head>
○ <body>
Demo
For .js file
IDE - Introduction To Visual Studio
● https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
Any Version
Demo
Getting Friendly with Visual Studio 2015
Modes Of Execution
● Immediate mode of script execution is writing script inside body tag and gets
executed as soon as page loads.
● Deferred mode of script execution is writing script in head tag and gets executed
on any event.
Demo
For both immediate and deferred modes
Data Types In JavaScript
● numbers
● strings
● arrays
● objects
● array of objects
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Single Variable Declaration
● var x;
● x=10;
● or
● var x=10;
● or
● x=10;
● var x=10;
● x=’Peter’;
● x=”John”;
● x=12.6;
Performing Operations - Require Operators
● Arithmetic : +,-,*,/,%
● Assignment : =, += (x+=y => x=x+y),-=,*=,%=
● Comparison : ==,===,!==,!===,<,<=,>,>=,
Demo
For All Operations
Control Structure
● Controlling the flow of our structure is achieved through the following statements
● Conditional
○ if, if else, else..if ladder and switch..case
● UnConditional
○ break, continue, goto and return. (Covered in functions)
● Iterative or Loop
Conditional Statements - if else
<script type="text/javascript">
var t=6;
if (t<10) {
document.write("<b>Good morning</b>");
}
else {
document.write("Good day!");
}
</script >
Conditional Statements - else if Ladder
<script type="text/javascript">
var t=16;
if (t<10) {
document.write("<b>Good morning</b>");
}
else if (t>10 && t<16) {
document.write("<b>Good day</b>");
}
else {
document.write("<b>Hello World!</b>");
}
</script>
Demo
For if, if else and else if ladder
Conditional Statements - switch case default
<script type="text/javascript">
theDay=5;
switch (theDay){
case 5: document.write("Finally Friday");
break;
case 6: document.write("Super Saturday");
break;
case 0: document.write("Sleepy Sunday");
break;
default: document.write("I'm looking forward to this weekend!");
}
</script>
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Demo
For switch case default
Iterative Statements - for
Syntax
for (statement 1; statement 2; statement 3) {
___________________
}
Ex:
for(i=0;i<10;i++){
document.write(“MTT”+<br/>);
}
Demo
For for loop
Iterative Statements - while
Syntax:
while (condition) {
___________
}
Eg:
i=0;
while(i<10){
document.write(“MTT”+<br/>);
i++;
}
Demo
For while loop
Iterative Statements - do while
Syntax:
do {
_____________
}
while (condition);
Eg:
i=0;
do{
document.write(“MTT”+<br/>);
i++;}
while(i<10);
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Demo
For do while
Array Variable Declaration
● An Array is collection of similar type of elements.
● It can be defined in three ways
● Literal Array: var x=[‘Peter’,’John’,’Bob’]; or var x=[]; //best approach
● Condensed Array: var x=new Array(‘Peter’,’John’,’Bob’);
● Regular Array: var x=new Array();
○ x[0]=’Peter’;
Demo
For arrays
Iterative Statements - for/in
Syntax:
for(item in list)
{
____________
}
Eg: var people=[‘Peter’,’John’,’Bob’];
for (i in people) {
document.write(people[i] +”<br/>”);
}
Demo
For for/in
Functions
● It is a set of instructions to perform a specific task.
● It can be classified into four categories.
○ No Parameter - No Return Value
○ With Parameter - No Return Value
○ No Parameter - With Return Value
○ With Parameter - With Return Value
Demo
Implementing functions
Types Of Variables or Scope Of Variables
● Local : Declared inside the function.
● Global : Declared outside the function.
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Demo
For Variables
Events
● Windows
● Form
● Keyboard
● Mouse
Windows Events
Major windows events
● onload
Eg:
<element onload="script">
Note:
● It is mostly used on <body> tag.
● Introduction to navigator object.
Demo
For Windows Events
Forms Events
Major events used with form elements
● onfocus : textbox
● onblur : textbox
● onchange : textbox and dropdown list
● onsubmit : form
Note:
● Introduction to getElementById object.
● Introduction to test() method of Regular Expression
Demo
For Form Events
Keyboard Events
Major Keyboard events are
● onkeydown //textbox
● onkeyup //textbox
● onkeypress //textbox
Note:
● Count number of characters in the textarea, like in twitter.
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Demo
For Keyboard Events
Mouse Events
Major mouse events
● onclick : button
● onmouseover : link
● onmouseout : link
Note:
● Introducing <marquee> tag
Demo
For Mouse Events
Creating
Calculator
● Basic Operations
● Introducing eval function
Demo
For Calculator
Stand Alone Object/s
● Single Object
○ var obj={“RollNo”:1, “Name”:"Peter", “Marks”:75};
○ obj.RollNo
● List Of Object
○ var lstObj=[{“RollNo”:1, “Name”:"Peter", “Marks”:75},
{“RollNo”:2, “Name”:"John", “Marks”:25},
{“RollNo”:3, “Name”:"Bob", “Marks”:35}]
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Demo
For Stand Alone Objects
Why OOPs?
● No strong binding between data and functions.
Demo
For Why OOPs
OOPs Through JavaScript
● Object
● Class
● Properties
● Methods
Analogy
Student
● rollNo
● name
● marks
● getDetails()
● getResult()
Properties
Methods
Class
● Objects
○ Jack
○ Peter
○ John
Object & Class
● Object
○ Any real time entity is called as an object.
○ Every object consist of state(look and feel) and behaviour(what is does).
○ States are called as properties and behaviors are called as methods.
● Classes
○ Class is a blueprint of an object.
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Constructor
● Constructor is invoked automatically when we create an object.
● You cannot invoke constructor explicitly.
● It is used to initialize an object.
● Here in javascript, it is slightly different.
Defining A
Class
function Student(){
this.rollNo=123;
this.name="ManzoorThetrainer";
this.marks=75;
this.getResult=function(){
if(this.marks>=35)
return “Pass”;
else
return “fail”;
}
}
● Javascript is prototype-oriented,
classless, or instance-based
programming.
● But we can simulate the class
concept using JavaScript functions.
Demo
For Defining A Class
Object Creation
var obj=new Student();
alert(obj.rollNo + “ ” obj.name);
alert(obj.getResult());
obj.rollNo=111;
obj.name=”Peter”;
obj.marks=23;
alert(obj.rollNo + “ ” obj.name);
alert(obj.getResult());
● Creating Object
● Accessing Properties
● Accessing Method
Demo
For Object Creation
Constructor
function Student(r,n,m){
this.rollNo=r;
this.name=n;
this.marks=m;
…
…
}
var obj=new Student(1,”Jack”,78);
alert(obj.rollNo + “ ” obj.name);
alert(obj.getResult());
● Creating Class
● Creating Object
● Accessing Properties
● Accessing Method
Demo
For Constructor
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
List Of Objects
function Student(r,n,m){
this.rollNo=r;
this.name=n;
this.marks=m;
…
…
}
var lstObj=new Array(); / [];
lstObj.push(new Student(1,”Jack”,78));
lstObj.push(new Student(2,”Peter”,81));
● Creating List Of Object
● Accessing Object’s Properties
● Accessing Object’s Method
Demo
For List Of Objects
Enroll Here
At 50% OFF - Use Coupon Code as ‘HALF-OFF’
Thanks

More Related Content

PPTX
Learn TypeScript from scratch
PDF
Java 2 e training
PDF
JavaScript Getting Started
PPTX
Kotlin programming language
PDF
Typescript for grails
PPTX
Webdev bootcamp
PDF
Don't Trust Your Users
PDF
AngularJS Basics
Learn TypeScript from scratch
Java 2 e training
JavaScript Getting Started
Kotlin programming language
Typescript for grails
Webdev bootcamp
Don't Trust Your Users
AngularJS Basics

What's hot (20)

PDF
Sharable of qualities of clean code
PPTX
Javascript in C# for Lightweight Applications
PPT
JavaScript Data Types
PPTX
Kickstarting Your Mongo Education with MongoDB University
PPTX
JavaScript | Introduction
PDF
PDF
Lightning talk: Kotlin
PPT
Introduction to Javascript
PDF
10 Groovy Little JavaScript Tips
PDF
ActiveDoc
PPTX
Introduction to JavaScript Programming
PPTX
Learn To Code: Introduction to java
PPTX
An introduction to Object Oriented JavaScript
PDF
Professional development
PDF
Building parsers in JavaScript
PPTX
Introduction to JavaScript
PDF
Agileee Developers Toolkit In The Agile World
PDF
Object Oriented Programming : Part 1
PDF
An Abusive Relationship with AngularJS
PPTX
Javascript 01 (js)
Sharable of qualities of clean code
Javascript in C# for Lightweight Applications
JavaScript Data Types
Kickstarting Your Mongo Education with MongoDB University
JavaScript | Introduction
Lightning talk: Kotlin
Introduction to Javascript
10 Groovy Little JavaScript Tips
ActiveDoc
Introduction to JavaScript Programming
Learn To Code: Introduction to java
An introduction to Object Oriented JavaScript
Professional development
Building parsers in JavaScript
Introduction to JavaScript
Agileee Developers Toolkit In The Agile World
Object Oriented Programming : Part 1
An Abusive Relationship with AngularJS
Javascript 01 (js)
Ad

Similar to Learn JavaScript From Scratch (20)

PPTX
UNIT 1 (7).pptx
PDF
Intro to Python for Non-Programmers
PDF
Introduction to web programming with JavaScript
PDF
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
PPT
Java script
ODP
Object Oriented Javascript
PDF
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
PDF
Optionals by Matt Faluotico
PDF
Software Developer Training
PDF
Python for web security - beginner
PDF
PPTX
Unit II- Java Script, DOM JQuery (2).pptx
PDF
Clojure Small Intro
PDF
Functional Programming 101 for Java 7 Developers
PPTX
Java script.pptx v
PDF
Dart workshop
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
PPTX
javascript client side scripting la.pptx
PDF
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
PPTX
Unity - NullReferenceException = ♥ / Aleksandr Kugushev (EPAM)
UNIT 1 (7).pptx
Intro to Python for Non-Programmers
Introduction to web programming with JavaScript
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Java script
Object Oriented Javascript
POUG Meetup 1st MArch 2019 - utPLSQL v3 - Testing Framework for PL/SQL
Optionals by Matt Faluotico
Software Developer Training
Python for web security - beginner
Unit II- Java Script, DOM JQuery (2).pptx
Clojure Small Intro
Functional Programming 101 for Java 7 Developers
Java script.pptx v
Dart workshop
Basic concept of Python.pptx includes design tool, identifier, variables.
javascript client side scripting la.pptx
Ukoug webinar - testing PLSQL APIs with utPLSQL v3
Unity - NullReferenceException = ♥ / Aleksandr Kugushev (EPAM)
Ad

More from Mohd Manzoor Ahmed (8)

PPTX
Live Project On ASP.Net Core 2.0 MVC - Free Webinar
PPTX
Angularjs Live Project
PPTX
Learn html and css from scratch
PPTX
Introduction to angular js for .net developers
PDF
C# simplified
PDF
Asp net-mvc-3 tier
PDF
MS.Net Interview Questions - Simplified
PPTX
3-TIER ARCHITECTURE IN ASP.NET MVC
Live Project On ASP.Net Core 2.0 MVC - Free Webinar
Angularjs Live Project
Learn html and css from scratch
Introduction to angular js for .net developers
C# simplified
Asp net-mvc-3 tier
MS.Net Interview Questions - Simplified
3-TIER ARCHITECTURE IN ASP.NET MVC

Recently uploaded (20)

PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
L1 - Introduction to python Backend.pptx
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
How Creative Agencies Leverage Project Management Software.pdf
Design an Analysis of Algorithms I-SECS-1021-03
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PTS Company Brochure 2025 (1).pdf.......
Operating system designcfffgfgggggggvggggggggg
Wondershare Filmora 15 Crack With Activation Key [2025
L1 - Introduction to python Backend.pptx
top salesforce developer skills in 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Design an Analysis of Algorithms II-SECS-1021-03
Softaken Excel to vCard Converter Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
How to Choose the Right IT Partner for Your Business in Malaysia
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context

Learn JavaScript From Scratch