SlideShare a Scribd company logo
01.01 Introduction
Introduction to JavaScript
01.01 Introduction
Welcome
• JavaScript has many uses, but we will
focus on Web Design, specifically how to
add interactivity
• In this class there is an assumption that
you are new to programming, but you
know HTML and CSS
01.01 Introduction
JavaScript and Client-Side Scripting
JavaScript is a client-side scripting language that
allows Web page authors to develop interactive Web
pages and sites.
Client-side scripting refers to a scripting language that
runs on a local browser (on the client tier) instead of on
a Web server (on the processing tier). Originally
designed for use in Navigator Web browsers,
JavaScript is now also used in most other Web
browsers, including Firefox and Internet Explorer.
01.01 Introduction
Cont..
JavaScript was originally developed as LiveScript by
Netscape in the mid 1990s. It was later renamed to
JavaScript in 1995, and became an ECMA standard in
1997. Now JavaScript is the standard client-side
scripting language for web-based applications, and it is
supported by virtually all web browsers available today,
such as Google Chrome, Mozilla Firefox, Apple Safari,
etc.
01.01 Introduction
Understanding Server-Side Scripting
Server-side scripting refers to a scripting language that
is executed from a Web server. Some of the more
popular server-side scripting languages are PHP, Active
Server Pages (ASP), and Java Server Pages
(JSP). One of the primary reasons for using a server-
side scripting language is to develop interactive Web
sites that communicate with a database.
01.01 Introduction
Conti..
Server-side scripting languages work in the processing
tier and have the ability to handle communication
between the client tier and the data storage tier. At the
processing tier, a server-side scripting language usually
prepares and processes the data in some way before
submitting it to the data storage tier.
01.01 Introduction
Adding JavaScript to Your Web Pages
Using the <script> Element
JavaScript programs run from within a Web page (either
an HTML or XHTML document). That is, you type the
code directly into the Web page code as a separate
section. JavaScript programs contained within
a Web page are often referred to as scripts. Th e
<script> element tells the Web browser that the scripting
engine must interpret the commands it contains.
01.01 Introduction
Conti..
The type attribute of the <script> element tells the
browser which scripting language and which version of
the scripting language is being used. You assign a value
of “text/javascript” to the type attribute to indicate that
the script is written with JavaScript.
<script type="text/javascript">
statements
</script>
01.01 Introduction
Embedding the JavaScript Code
You can embed the JavaScript code directly within your
web pages by placing it between the <script> and
</script> tags. Here's an example:
<body>
<script>
var salaan = "Hello World!";
document.write(salaan); // Prints: Hello World!
</script>
</body>
01.01 Introduction
Calling an External JavaScript File
You can also place your JavaScript code into a separate
file with a .js extension, and then call that file in your
document through the src attribute of the <script> tag,
like this:
<script src="js/hello.js"></script>
This is useful if you want the same scripts available to
multiple documents. It saves you from repeating the
same task over and over again, and makes your website
much easier to maintain.
01.01 Introduction
Conti..
Example
// A function to display a message
function sayHello() {
alert("Hello World!");
}
// Call function on click of the button
document.getElementById("myBtn").onclick = sayHello;
01.01 Introduction
Conti..
Example
html>
<head>
<title>Including External JavaScript File</title>
</head>
<body>
<button type="button" id="myBtn">Click Me</button>
<script src="hello.js"></script>
</body>
</html>
01.01 Introduction
Placing the JavaScript Code Inline
You can also place JavaScript code inline by inserting it
directly inside the HTML tag using the special tag
attributes such as onclick, onmouseover, onkeypress,
onload, etc.
<body>
<button onclick="alert('Hello World!')">Click
Me</button>
</body>
01.01 Introduction
Case Sensitivity in JavaScript
JavaScript is case-sensitive. This means that variables,
language keywords, function names, and other
identifiers must always be typed with a consistent
capitalization of letters.
For example, the variable myVar must be typed myVar
not MyVar or myvar. Similarly, the method name
getElementById() must be typed with the exact case not
as getElementByID().
01.01 Introduction
Adding Comments to a JavaScript
Comments are nonprinting lines that
you place in your code to contain various types of
remarks, including the name of the program, your name
and the date you created the program, or instructions to
future programmers who may need to modify your work.
JavaScript support single-line as well as multi-line
comments. Single-line comments begin with a double
forward slash (//).Whereas, a multi-line comment begins
with a slash and an asterisk (/*) and ends with an asterisk
and slash (*/).
01.01 Introduction
Conti...
Example of Single Comment
// This is my first JavaScript program
document.write("Hello World!");
Example of Multi-line Comment
/* This is my first program
in JavaScript */
document.write("Hello World!");
01.01 Introduction
Variables
The values a program stores in computer memory are
commonly called variables. The data or value stored in the
variables can be set, updated, and retrieved whenever
needed. You can create or declare JavaScript a variable
using 3 keywords that are var, let, and const, whereas the
assignment operator (=) is used to assign value to a
variable, like this: var varName = value;
01.01 Introduction
Conti…
var keyword: The var is the oldest keyword to declare a
variable in JavaScript.
<script>
var a = 10;
Console.log(a);
</script>
01.01 Introduction
Conti…
let keyword: The let keyword is an improved version of the
var keyword.
<script>
<script>
let a = 10;
let b = 9
console.log(b);
console.log(a);
</script>
01.01 Introduction
Conti…
const keyword: The const keyword has all the properties
that are the same as the let keyword, except the user
cannot update it.
<script>
const a = 10;
a = 9
console.log(a)
</script>
01.01 Introduction
Conti…
var let const
The scope of a var variable
is functional scope.
The scope of a let variable
is block scope.
The scope of
a const variable is block
scope.
It can be updated and re-
declared into the scope.
It can be updated but
cannot be re-declared into
the scope.
It cannot be updated or re-
declared into the scope.
It can be declared without
initialization.
It can be declared without
initialization.
It cannot be declared
without initialization.
01.01 Introduction
Cont..
Example
var name = "Peter Parker";
var age = 21;
var isMarried = false;
// Displaying a variable value
var x = 10;
var y = 20;
var sum = x + y;
alert(sum); // Outputs: 30
INTERACTIVITY
WITH JAVASCRIPT
01.01 Introduction
Naming Conventions for JavaScript Variables
These are the following rules for naming a JavaScript
variable:
• A variable name must start with a letter, underscore (_),
or dollar sign ($).
• A variable name cannot start with a number.
• A variable name can only contain alpha-numeric
characters (A-z, 0-9) and underscores.
• A variable name cannot contain spaces.
• A variable name cannot be a JavaScript keyword or a
JavaScript reserved word.

More Related Content

What's hot

JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
Edureka!
 
Coding standard
Coding standardCoding standard
Coding standard
FAROOK Samath
 
Introduction to JavaScript (1).ppt
Introduction to JavaScript (1).pptIntroduction to JavaScript (1).ppt
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
Coding standards and guidelines
Coding standards and guidelinesCoding standards and guidelines
Coding standards and guidelines
brijraj_singh
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
Zunair Sagitarioux
 
Javascript
JavascriptJavascript
Javascript
Nagarajan
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 
HTML5 Canvas - Basics.pptx
HTML5 Canvas - Basics.pptxHTML5 Canvas - Basics.pptx
HTML5 Canvas - Basics.pptx
AhmadAbba6
 
JavaScript
JavaScriptJavaScript
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transformKenny Lee
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
FaysalAhammed5
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
Javascript
JavascriptJavascript
Javascript
guest03a6e6
 
Css gradients
Css gradientsCss gradients
Css gradients
skyler hildreth
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
 

What's hot (20)

JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
 
Coding standard
Coding standardCoding standard
Coding standard
 
Introduction to JavaScript (1).ppt
Introduction to JavaScript (1).pptIntroduction to JavaScript (1).ppt
Introduction to JavaScript (1).ppt
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Coding standards and guidelines
Coding standards and guidelinesCoding standards and guidelines
Coding standards and guidelines
 
Responsive web-design through bootstrap
Responsive web-design through bootstrapResponsive web-design through bootstrap
Responsive web-design through bootstrap
 
Javascript
JavascriptJavascript
Javascript
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
HTML5 Canvas - Basics.pptx
HTML5 Canvas - Basics.pptxHTML5 Canvas - Basics.pptx
HTML5 Canvas - Basics.pptx
 
JavaScript
JavaScriptJavaScript
JavaScript
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transform
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
Javascript
JavascriptJavascript
Javascript
 
Css gradients
Css gradientsCss gradients
Css gradients
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Css box model
Css  box modelCss  box model
Css box model
 

Similar to Introduction to JavaScript.pptx

Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
shafiq sangi
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptx
rish15r890
 
JavaScript
JavaScriptJavaScript
JavaScript
Gulbir Chaudhary
 
Web development intership Presentation.pptx
Web development intership Presentation.pptxWeb development intership Presentation.pptx
Web development intership Presentation.pptx
bodepallivamsi1122
 
CHAPTER 3 JS (1).pptx
CHAPTER 3  JS (1).pptxCHAPTER 3  JS (1).pptx
CHAPTER 3 JS (1).pptx
achutachut
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scriptsch samaram
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
JonnJorellPunto
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
BEAAUTIFUL presentation of java
BEAAUTIFUL  presentation of javaBEAAUTIFUL  presentation of java
BEAAUTIFUL presentation of java
rana usman
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
Go4Guru
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
ApxicTechnologies1
 
Lecture-15.pptx
Lecture-15.pptxLecture-15.pptx
Lecture-15.pptx
vishal choudhary
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
JohnLagman3
 
Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web Development
Parvez Mahbub
 

Similar to Introduction to JavaScript.pptx (20)

Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptx
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Web development intership Presentation.pptx
Web development intership Presentation.pptxWeb development intership Presentation.pptx
Web development intership Presentation.pptx
 
CHAPTER 3 JS (1).pptx
CHAPTER 3  JS (1).pptxCHAPTER 3  JS (1).pptx
CHAPTER 3 JS (1).pptx
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
 
BEAAUTIFUL presentation of java
BEAAUTIFUL  presentation of javaBEAAUTIFUL  presentation of java
BEAAUTIFUL presentation of java
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Lecture-15.pptx
Lecture-15.pptxLecture-15.pptx
Lecture-15.pptx
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
 
Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web Development
 

Recently uploaded

Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Sérgio Sacani
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
sanjana502982
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
University of Maribor
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
pablovgd
 
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
David Osipyan
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
kejapriya1
 
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptxANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
RASHMI M G
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
ChetanK57
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
fafyfskhan251kmf
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
Sharon Liu
 
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdfMudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
frank0071
 
Introduction to Mean Field Theory(MFT).pptx
Introduction to Mean Field Theory(MFT).pptxIntroduction to Mean Field Theory(MFT).pptx
Introduction to Mean Field Theory(MFT).pptx
zeex60
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
RenuJangid3
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
KrushnaDarade1
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
silvermistyshot
 
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Studia Poinsotiana
 
Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.
Nistarini College, Purulia (W.B) India
 
Nutraceutical market, scope and growth: Herbal drug technology
Nutraceutical market, scope and growth: Herbal drug technologyNutraceutical market, scope and growth: Herbal drug technology
Nutraceutical market, scope and growth: Herbal drug technology
Lokesh Patil
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
Richard Gill
 
platelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptxplatelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptx
muralinath2
 

Recently uploaded (20)

Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
 
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
3D Hybrid PIC simulation of the plasma expansion (ISSS-14)
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
 
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptxANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptx
 
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATIONPRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
PRESENTATION ABOUT PRINCIPLE OF COSMATIC EVALUATION
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
 
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdfMudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
Mudde & Rovira Kaltwasser. - Populism - a very short introduction [2017].pdf
 
Introduction to Mean Field Theory(MFT).pptx
Introduction to Mean Field Theory(MFT).pptxIntroduction to Mean Field Theory(MFT).pptx
Introduction to Mean Field Theory(MFT).pptx
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
 
Lateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensiveLateral Ventricles.pdf very easy good diagrams comprehensive
Lateral Ventricles.pdf very easy good diagrams comprehensive
 
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
Salas, V. (2024) "John of St. Thomas (Poinsot) on the Science of Sacred Theol...
 
Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.Nucleic Acid-its structural and functional complexity.
Nucleic Acid-its structural and functional complexity.
 
Nutraceutical market, scope and growth: Herbal drug technology
Nutraceutical market, scope and growth: Herbal drug technologyNutraceutical market, scope and growth: Herbal drug technology
Nutraceutical market, scope and growth: Herbal drug technology
 
Richard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlandsRichard's aventures in two entangled wonderlands
Richard's aventures in two entangled wonderlands
 
platelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptxplatelets_clotting_biogenesis.clot retractionpptx
platelets_clotting_biogenesis.clot retractionpptx
 

Introduction to JavaScript.pptx

  • 2. 01.01 Introduction Welcome • JavaScript has many uses, but we will focus on Web Design, specifically how to add interactivity • In this class there is an assumption that you are new to programming, but you know HTML and CSS
  • 3. 01.01 Introduction JavaScript and Client-Side Scripting JavaScript is a client-side scripting language that allows Web page authors to develop interactive Web pages and sites. Client-side scripting refers to a scripting language that runs on a local browser (on the client tier) instead of on a Web server (on the processing tier). Originally designed for use in Navigator Web browsers, JavaScript is now also used in most other Web browsers, including Firefox and Internet Explorer.
  • 4. 01.01 Introduction Cont.. JavaScript was originally developed as LiveScript by Netscape in the mid 1990s. It was later renamed to JavaScript in 1995, and became an ECMA standard in 1997. Now JavaScript is the standard client-side scripting language for web-based applications, and it is supported by virtually all web browsers available today, such as Google Chrome, Mozilla Firefox, Apple Safari, etc.
  • 5. 01.01 Introduction Understanding Server-Side Scripting Server-side scripting refers to a scripting language that is executed from a Web server. Some of the more popular server-side scripting languages are PHP, Active Server Pages (ASP), and Java Server Pages (JSP). One of the primary reasons for using a server- side scripting language is to develop interactive Web sites that communicate with a database.
  • 6. 01.01 Introduction Conti.. Server-side scripting languages work in the processing tier and have the ability to handle communication between the client tier and the data storage tier. At the processing tier, a server-side scripting language usually prepares and processes the data in some way before submitting it to the data storage tier.
  • 7. 01.01 Introduction Adding JavaScript to Your Web Pages Using the <script> Element JavaScript programs run from within a Web page (either an HTML or XHTML document). That is, you type the code directly into the Web page code as a separate section. JavaScript programs contained within a Web page are often referred to as scripts. Th e <script> element tells the Web browser that the scripting engine must interpret the commands it contains.
  • 8. 01.01 Introduction Conti.. The type attribute of the <script> element tells the browser which scripting language and which version of the scripting language is being used. You assign a value of “text/javascript” to the type attribute to indicate that the script is written with JavaScript. <script type="text/javascript"> statements </script>
  • 9. 01.01 Introduction Embedding the JavaScript Code You can embed the JavaScript code directly within your web pages by placing it between the <script> and </script> tags. Here's an example: <body> <script> var salaan = "Hello World!"; document.write(salaan); // Prints: Hello World! </script> </body>
  • 10. 01.01 Introduction Calling an External JavaScript File You can also place your JavaScript code into a separate file with a .js extension, and then call that file in your document through the src attribute of the <script> tag, like this: <script src="js/hello.js"></script> This is useful if you want the same scripts available to multiple documents. It saves you from repeating the same task over and over again, and makes your website much easier to maintain.
  • 11. 01.01 Introduction Conti.. Example // A function to display a message function sayHello() { alert("Hello World!"); } // Call function on click of the button document.getElementById("myBtn").onclick = sayHello;
  • 12. 01.01 Introduction Conti.. Example html> <head> <title>Including External JavaScript File</title> </head> <body> <button type="button" id="myBtn">Click Me</button> <script src="hello.js"></script> </body> </html>
  • 13. 01.01 Introduction Placing the JavaScript Code Inline You can also place JavaScript code inline by inserting it directly inside the HTML tag using the special tag attributes such as onclick, onmouseover, onkeypress, onload, etc. <body> <button onclick="alert('Hello World!')">Click Me</button> </body>
  • 14. 01.01 Introduction Case Sensitivity in JavaScript JavaScript is case-sensitive. This means that variables, language keywords, function names, and other identifiers must always be typed with a consistent capitalization of letters. For example, the variable myVar must be typed myVar not MyVar or myvar. Similarly, the method name getElementById() must be typed with the exact case not as getElementByID().
  • 15. 01.01 Introduction Adding Comments to a JavaScript Comments are nonprinting lines that you place in your code to contain various types of remarks, including the name of the program, your name and the date you created the program, or instructions to future programmers who may need to modify your work. JavaScript support single-line as well as multi-line comments. Single-line comments begin with a double forward slash (//).Whereas, a multi-line comment begins with a slash and an asterisk (/*) and ends with an asterisk and slash (*/).
  • 16. 01.01 Introduction Conti... Example of Single Comment // This is my first JavaScript program document.write("Hello World!"); Example of Multi-line Comment /* This is my first program in JavaScript */ document.write("Hello World!");
  • 17. 01.01 Introduction Variables The values a program stores in computer memory are commonly called variables. The data or value stored in the variables can be set, updated, and retrieved whenever needed. You can create or declare JavaScript a variable using 3 keywords that are var, let, and const, whereas the assignment operator (=) is used to assign value to a variable, like this: var varName = value;
  • 18. 01.01 Introduction Conti… var keyword: The var is the oldest keyword to declare a variable in JavaScript. <script> var a = 10; Console.log(a); </script>
  • 19. 01.01 Introduction Conti… let keyword: The let keyword is an improved version of the var keyword. <script> <script> let a = 10; let b = 9 console.log(b); console.log(a); </script>
  • 20. 01.01 Introduction Conti… const keyword: The const keyword has all the properties that are the same as the let keyword, except the user cannot update it. <script> const a = 10; a = 9 console.log(a) </script>
  • 21. 01.01 Introduction Conti… var let const The scope of a var variable is functional scope. The scope of a let variable is block scope. The scope of a const variable is block scope. It can be updated and re- declared into the scope. It can be updated but cannot be re-declared into the scope. It cannot be updated or re- declared into the scope. It can be declared without initialization. It can be declared without initialization. It cannot be declared without initialization.
  • 22. 01.01 Introduction Cont.. Example var name = "Peter Parker"; var age = 21; var isMarried = false; // Displaying a variable value var x = 10; var y = 20; var sum = x + y; alert(sum); // Outputs: 30
  • 23. INTERACTIVITY WITH JAVASCRIPT 01.01 Introduction Naming Conventions for JavaScript Variables These are the following rules for naming a JavaScript variable: • A variable name must start with a letter, underscore (_), or dollar sign ($). • A variable name cannot start with a number. • A variable name can only contain alpha-numeric characters (A-z, 0-9) and underscores. • A variable name cannot contain spaces. • A variable name cannot be a JavaScript keyword or a JavaScript reserved word.