SlideShare a Scribd company logo
3
Advantages and Disadvantages 
ADVANTAGES 
Runs Fast: Most of the JavaScript task runs 
without contacting to the server. 
Platform Independent. 
Easy to Learn. 
Increased interactivity: You can create 
interfaces that react on the user interactions. 
Richer interfaces: You can use JavaScript to 
include such items as drag-and-drop 
components and sliders to give a Rich 
Interface to your site visitors. 
DISADVANTAGES 
Runs on single thread: There is no 
multithreading or multiprocessing capabilities. 
Read/Write Files: JavaScript does not allow 
the reading or writing of files. This has been 
kept for security reason. 
Networking applications: JavaScript can not 
be used for Networking applications because 
there is no such support available. 
Code is not hidden: Code is always visible to 
client end, even though it is minified.
Most read
6
JavaScript Syntax (Functions and Events) 
For adding functions in JavaScript “function” keyword is used. 
function functionName(param1, param2,…,paramN){ 
//Code to be executed. 
return anyValue; //return is used if function return any value otherwise not. 
} 
Functions can be accessed by their names like “functionName(1,2);” 
Functions can be called any event occur like onclick event of button. 
<button onclick=“functionName()”>Press It</button> 
In Events single statement can also be executed with out calling the function. 
<button onclick=“this.innerHTML=Date()”>Press It</button>
Most read
9
JavaScript HTML DOM 
With the HTML DOM, JavaScript can access and change all the elements of an HTML document. 
In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML 
elements. 
When web page is loaded, browser creates a Document Object Model of the page as for 
example: 
<html> 
<head> 
<title> 
My title 
</title> 
</head> 
<body> 
<a href=“#”>My link</a> 
<h1>My header</h1> 
</body> 
</html>
Most read
JavaScript Basics 
PRESENTED BY: HASSAN AHMED BAIG
Introduction 
JavaScript is the programming language of the Web that runs on client end. 
All modern HTML pages are using JavaScript. 
JavaScript enhances Web pages with dynamic and interactive features like: 
 Shopping carts 
 Form Validation 
 Calculations 
 Special graphic and text effects 
 Image swapping 
 and many more.
Advantages and Disadvantages 
ADVANTAGES 
Runs Fast: Most of the JavaScript task runs 
without contacting to the server. 
Platform Independent. 
Easy to Learn. 
Increased interactivity: You can create 
interfaces that react on the user interactions. 
Richer interfaces: You can use JavaScript to 
include such items as drag-and-drop 
components and sliders to give a Rich 
Interface to your site visitors. 
DISADVANTAGES 
Runs on single thread: There is no 
multithreading or multiprocessing capabilities. 
Read/Write Files: JavaScript does not allow 
the reading or writing of files. This has been 
kept for security reason. 
Networking applications: JavaScript can not 
be used for Networking applications because 
there is no such support available. 
Code is not hidden: Code is always visible to 
client end, even though it is minified.
Where JavaScript Is Placed 
In HTML, JavaScripts must be inserted between <script> and </script> tags either in <head> or 
<body> tag. 
<html> 
<head> 
<script> 
</script> 
</head> 
<body> 
<script> 
</script> 
</body> 
</html> 
JavaScript code comes here. 
External JavaScript can also be inserted using “<script src="myScript.js"></script>”.
JavaScript Syntax (Variables) 
For single line comments “//” is used and for multiline comments “/* */” is used. 
Variables are declared using “var” keyword. 
var pi = 3.14; 
var person = “Hassan Ahmed Baig“, var company= ’eDev’; 
var x = 5; 
var tested = true; 
var lastName = “Baig", x = 30, job = “Developer"; 
var carName; 
var cars = ["Saab", "Volvo", "BMW"]; 
var person = {firstName:“Hassan", lastName:“Baig", age:50, job:“Developer"}; 
Floating, String, 
Numeric and 
boolean Variables 
One Statement, Many Variables 
If value is not defined 
Arrays are defined then Value = Undefined 
using square brackets 
In JavaScript Objects properties 
are written in key value pair. 
Properties can be accessed as 
“person.firstName”.
JavaScript Syntax (Functions and Events) 
For adding functions in JavaScript “function” keyword is used. 
function functionName(param1, param2,…,paramN){ 
//Code to be executed. 
return anyValue; //return is used if function return any value otherwise not. 
} 
Functions can be accessed by their names like “functionName(1,2);” 
Functions can be called any event occur like onclick event of button. 
<button onclick=“functionName()”>Press It</button> 
In Events single statement can also be executed with out calling the function. 
<button onclick=“this.innerHTML=Date()”>Press It</button>
JavaScript Syntax (Conditions) 
Conditions in JavaScript are “if”, “if else”, “if else if” and “switch”. 
if (condition) { 
code to be executed if the condition is true 
} 
if (condition) { 
code to be executed if the condition is true 
}else{ 
code to be executed if the condition is false 
} 
if (condition1) { 
code to be executed if condition1 is true 
} else if (condition2) { 
code to be executed if the condition1 is false and condition2 is true 
} else { 
code to be executed if the condition1 is false and condition2 is false 
} 
switch(expression) { 
case n: 
code block 
break; 
case n: 
code block 
break; 
default: 
default code block 
}
JavaScript Syntax (Loops) 
Loops in JavaScript are “for”, “for/in”, “while” and “do/while”. 
for (initialization; condition; increment) { 
code block to be executed 
} 
For example: 
for (i = 0; i < 5; i++) { 
text += "The number is " + i + "<br>"; 
} 
For/in is used to iterate the properties of an object. 
var person = {fname:“Hassan”, lname:“Baig”, age:50}; 
var text = ""; 
var propertyName; 
for (propertyName in person) { 
text += “PropertyName: ” + propertyName; 
text += “PropertyValue: ” + person[propertyName ]; 
} 
while (condition) { 
code block to be executed 
} 
do { 
code block to be executed 
} 
while (condition);
JavaScript HTML DOM 
With the HTML DOM, JavaScript can access and change all the elements of an HTML document. 
In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML 
elements. 
When web page is loaded, browser creates a Document Object Model of the page as for 
example: 
<html> 
<head> 
<title> 
My title 
</title> 
</head> 
<body> 
<a href=“#”>My link</a> 
<h1>My header</h1> 
</body> 
</html>
Finding Element In HTML DOM 
Elements can be found by their “ID”, “Tag Name”, “Class Name”. 
“document.getElementById()” is used to find the element by their ids. 
“document.getElementsByTagName()” is used to find the element by the tag name. 
 Eg: document. getElementsByTagName(“header”); 
“document.getElementsByClassName()” is used to find the element by the class name. 
 Eg: document. getElementsByClassName(“logo”);
Changing HTML 
HTML of any element can be modified by “innerHTML” property as follows: 
Value of any attribute of an element can also be changed as follows: 
<p id=“name"><strong>Hassan 
</strong></p> 
Hassan 
document.getElementById(“name”).innerHTML = ”<strong>Hassan</strong>” 
<p id=“name">Hassan</p> 
Hassan 
document.getElementById(“<img src=“abc.jpg” > name”).src= ”xyz.jpg” <img src=“xyz.jpg” >
Changing CSS 
Style of any element can be modified by “style” property as follows: 
<p id=“name“ style=“color:blue”>Hassan</p> 
Hassan 
document.getElementById(“name”).style.color = ”blue” 
<p id=“name">Hassan</p> 
Hassan 
document.getElementById(id).style.property=new style
Register Event Using HTML DOM 
Events can also be registered to any element using JavaScript HTML DOM as follows: 
document.getElementById("myBtn").onclick = function(){ 
//code to be executed. 
};

More Related Content

What's hot (20)

Java script
Java scriptJava script
Java script
Abhishek Kesharwani
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
Javascript event handler
Javascript event handlerJavascript event handler
Javascript event handler
Jesus Obenita Jr.
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Priya Goyal
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
Jalpesh Vasa
 
Angular Directives
Angular DirectivesAngular Directives
Angular Directives
Malla Reddy University
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 
Js ppt
Js pptJs ppt
Js ppt
Rakhi Thota
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
Bui Kiet
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
Bedis ElAchèche
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!HTML, CSS And JAVASCRIPT!
HTML, CSS And JAVASCRIPT!
Syahmi RH
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
Dave Kelly
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
 
Javascript
JavascriptJavascript
Javascript
Nagarajan
 

Viewers also liked (14)

Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Javascript
JavascriptJavascript
Javascript
guest03a6e6
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
guestceb98b
 
JavaScript 101 for Microsoft CRM 2011
JavaScript 101 for Microsoft CRM 2011JavaScript 101 for Microsoft CRM 2011
JavaScript 101 for Microsoft CRM 2011
Will Slade
 
DEFINE FRAME AND FRAME SET WITH A EXAMPLE
DEFINE FRAME AND FRAME SET WITH A EXAMPLEDEFINE FRAME AND FRAME SET WITH A EXAMPLE
DEFINE FRAME AND FRAME SET WITH A EXAMPLE
Vaibhav Sinha
 
Html frames
Html framesHtml frames
Html frames
Arslan Elahi
 
HTML Frameset & Inline Frame
HTML Frameset & Inline FrameHTML Frameset & Inline Frame
HTML Frameset & Inline Frame
Nisa Soomro
 
HTML frames and HTML forms
HTML frames and HTML formsHTML frames and HTML forms
HTML frames and HTML forms
Nadine Cruz
 
Html Frames
Html FramesHtml Frames
Html Frames
Xainab Ishfaq
 
Javascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRMJavascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRM
Ashish Vishwakarma
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Java script ppt
Java script pptJava script ppt
Java script ppt
The Health and Social Care Information Centre
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
guestceb98b
 
JavaScript 101 for Microsoft CRM 2011
JavaScript 101 for Microsoft CRM 2011JavaScript 101 for Microsoft CRM 2011
JavaScript 101 for Microsoft CRM 2011
Will Slade
 
DEFINE FRAME AND FRAME SET WITH A EXAMPLE
DEFINE FRAME AND FRAME SET WITH A EXAMPLEDEFINE FRAME AND FRAME SET WITH A EXAMPLE
DEFINE FRAME AND FRAME SET WITH A EXAMPLE
Vaibhav Sinha
 
HTML Frameset & Inline Frame
HTML Frameset & Inline FrameHTML Frameset & Inline Frame
HTML Frameset & Inline Frame
Nisa Soomro
 
HTML frames and HTML forms
HTML frames and HTML formsHTML frames and HTML forms
HTML frames and HTML forms
Nadine Cruz
 
Javascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRMJavascript & OData Microsoft Dynamics CRM
Javascript & OData Microsoft Dynamics CRM
Ashish Vishwakarma
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Ad

Similar to Introduction to JavaScript Basics. (20)

javaScript and jQuery
javaScript and jQueryjavaScript and jQuery
javaScript and jQuery
Mehrab Hossain
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 
Java script
Java scriptJava script
Java script
Shyam Khant
 
JavaScript_III.pptx
JavaScript_III.pptxJavaScript_III.pptx
JavaScript_III.pptx
rashmiisrani1
 
Java script
Java scriptJava script
Java script
Jay Patel
 
Java script
 Java script Java script
Java script
bosybosy
 
wp-UNIT_III.pptx
wp-UNIT_III.pptxwp-UNIT_III.pptx
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
JavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQueryJavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
BITM3730Week6.pptx
BITM3730Week6.pptxBITM3730Week6.pptx
BITM3730Week6.pptx
MattMarino13
 
Javascript Basics by Bonny
Javascript Basics by BonnyJavascript Basics by Bonny
Javascript Basics by Bonny
Bonny Chacko
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
Soumen Santra
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting Started
Hazem Hagrass
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
Unit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatioUnit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
javascriptPresentation.pdf
javascriptPresentation.pdfjavascriptPresentation.pdf
javascriptPresentation.pdf
wildcat9335
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
Mujtaba Haider
 
WT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And DomWT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And Dom
SrushtiGhise
 
Presentation JavaScript Introduction Data Types Variables Control Structure
Presentation JavaScript Introduction  Data Types Variables Control StructurePresentation JavaScript Introduction  Data Types Variables Control Structure
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
Learn JavaScript From Scratch
Learn JavaScript From ScratchLearn JavaScript From Scratch
Learn JavaScript From Scratch
Mohd Manzoor Ahmed
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 
Java script
 Java script Java script
Java script
bosybosy
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
JavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQueryJavaScript Fundamentals & JQuery
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
BITM3730Week6.pptx
BITM3730Week6.pptxBITM3730Week6.pptx
BITM3730Week6.pptx
MattMarino13
 
Javascript Basics by Bonny
Javascript Basics by BonnyJavascript Basics by Bonny
Javascript Basics by Bonny
Bonny Chacko
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
Soumen Santra
 
JavaScript Getting Started
JavaScript Getting StartedJavaScript Getting Started
JavaScript Getting Started
Hazem Hagrass
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
Unit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatioUnit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
javascriptPresentation.pdf
javascriptPresentation.pdfjavascriptPresentation.pdf
javascriptPresentation.pdf
wildcat9335
 
WT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And DomWT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And Dom
SrushtiGhise
 
Presentation JavaScript Introduction Data Types Variables Control Structure
Presentation JavaScript Introduction  Data Types Variables Control StructurePresentation JavaScript Introduction  Data Types Variables Control Structure
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
Ad

Recently uploaded (20)

IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-OffMicro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Tier1 app
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlowDevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptxIMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
IMAGE CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK.P.pptx
usmanch7829
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
Plooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your wayPlooma is a writing platform to plan, write, and shape books your way
Plooma is a writing platform to plan, write, and shape books your way
Plooma
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!Build enterprise-ready applications using skills you already have!
Build enterprise-ready applications using skills you already have!
PhilMeredith3
 
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentricIntegration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Integration Ignited Redefining Event-Driven Architecture at Wix - EventCentric
Natan Silnitsky
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-OffMicro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Micro-Metrics Every Performance Engineer Should Validate Before Sign-Off
Tier1 app
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink TemplateeeeeeeeeeeeeeeeeeeeeeeeeeNeuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
Neuralink Templateeeeeeeeeeeeeeeeeeeeeeeeee
alexandernoetzold
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
OpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native BarcelonaOpenTelemetry 101 Cloud Native Barcelona
OpenTelemetry 101 Cloud Native Barcelona
Imma Valls Bernaus
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlowDevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 

Introduction to JavaScript Basics.

  • 1. JavaScript Basics PRESENTED BY: HASSAN AHMED BAIG
  • 2. Introduction JavaScript is the programming language of the Web that runs on client end. All modern HTML pages are using JavaScript. JavaScript enhances Web pages with dynamic and interactive features like:  Shopping carts  Form Validation  Calculations  Special graphic and text effects  Image swapping  and many more.
  • 3. Advantages and Disadvantages ADVANTAGES Runs Fast: Most of the JavaScript task runs without contacting to the server. Platform Independent. Easy to Learn. Increased interactivity: You can create interfaces that react on the user interactions. Richer interfaces: You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors. DISADVANTAGES Runs on single thread: There is no multithreading or multiprocessing capabilities. Read/Write Files: JavaScript does not allow the reading or writing of files. This has been kept for security reason. Networking applications: JavaScript can not be used for Networking applications because there is no such support available. Code is not hidden: Code is always visible to client end, even though it is minified.
  • 4. Where JavaScript Is Placed In HTML, JavaScripts must be inserted between <script> and </script> tags either in <head> or <body> tag. <html> <head> <script> </script> </head> <body> <script> </script> </body> </html> JavaScript code comes here. External JavaScript can also be inserted using “<script src="myScript.js"></script>”.
  • 5. JavaScript Syntax (Variables) For single line comments “//” is used and for multiline comments “/* */” is used. Variables are declared using “var” keyword. var pi = 3.14; var person = “Hassan Ahmed Baig“, var company= ’eDev’; var x = 5; var tested = true; var lastName = “Baig", x = 30, job = “Developer"; var carName; var cars = ["Saab", "Volvo", "BMW"]; var person = {firstName:“Hassan", lastName:“Baig", age:50, job:“Developer"}; Floating, String, Numeric and boolean Variables One Statement, Many Variables If value is not defined Arrays are defined then Value = Undefined using square brackets In JavaScript Objects properties are written in key value pair. Properties can be accessed as “person.firstName”.
  • 6. JavaScript Syntax (Functions and Events) For adding functions in JavaScript “function” keyword is used. function functionName(param1, param2,…,paramN){ //Code to be executed. return anyValue; //return is used if function return any value otherwise not. } Functions can be accessed by their names like “functionName(1,2);” Functions can be called any event occur like onclick event of button. <button onclick=“functionName()”>Press It</button> In Events single statement can also be executed with out calling the function. <button onclick=“this.innerHTML=Date()”>Press It</button>
  • 7. JavaScript Syntax (Conditions) Conditions in JavaScript are “if”, “if else”, “if else if” and “switch”. if (condition) { code to be executed if the condition is true } if (condition) { code to be executed if the condition is true }else{ code to be executed if the condition is false } if (condition1) { code to be executed if condition1 is true } else if (condition2) { code to be executed if the condition1 is false and condition2 is true } else { code to be executed if the condition1 is false and condition2 is false } switch(expression) { case n: code block break; case n: code block break; default: default code block }
  • 8. JavaScript Syntax (Loops) Loops in JavaScript are “for”, “for/in”, “while” and “do/while”. for (initialization; condition; increment) { code block to be executed } For example: for (i = 0; i < 5; i++) { text += "The number is " + i + "<br>"; } For/in is used to iterate the properties of an object. var person = {fname:“Hassan”, lname:“Baig”, age:50}; var text = ""; var propertyName; for (propertyName in person) { text += “PropertyName: ” + propertyName; text += “PropertyValue: ” + person[propertyName ]; } while (condition) { code block to be executed } do { code block to be executed } while (condition);
  • 9. JavaScript HTML DOM With the HTML DOM, JavaScript can access and change all the elements of an HTML document. In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements. When web page is loaded, browser creates a Document Object Model of the page as for example: <html> <head> <title> My title </title> </head> <body> <a href=“#”>My link</a> <h1>My header</h1> </body> </html>
  • 10. Finding Element In HTML DOM Elements can be found by their “ID”, “Tag Name”, “Class Name”. “document.getElementById()” is used to find the element by their ids. “document.getElementsByTagName()” is used to find the element by the tag name.  Eg: document. getElementsByTagName(“header”); “document.getElementsByClassName()” is used to find the element by the class name.  Eg: document. getElementsByClassName(“logo”);
  • 11. Changing HTML HTML of any element can be modified by “innerHTML” property as follows: Value of any attribute of an element can also be changed as follows: <p id=“name"><strong>Hassan </strong></p> Hassan document.getElementById(“name”).innerHTML = ”<strong>Hassan</strong>” <p id=“name">Hassan</p> Hassan document.getElementById(“<img src=“abc.jpg” > name”).src= ”xyz.jpg” <img src=“xyz.jpg” >
  • 12. Changing CSS Style of any element can be modified by “style” property as follows: <p id=“name“ style=“color:blue”>Hassan</p> Hassan document.getElementById(“name”).style.color = ”blue” <p id=“name">Hassan</p> Hassan document.getElementById(id).style.property=new style
  • 13. Register Event Using HTML DOM Events can also be registered to any element using JavaScript HTML DOM as follows: document.getElementById("myBtn").onclick = function(){ //code to be executed. };