SlideShare a Scribd company logo
Introduction to
JavaScript
2
Topics
 What is JavaScript?
 Why JavaScript?
 Including JavaScript in HTML
 Hello World Example Script
 JavaScript Comments
3
What is JavaScript?
 Created by Netscape
 Originally called LiveWire then LiveScript
 A client-side scripting language
 Client-side refers to the fact that it is executed in
the client (software) that the viewer is using. In
the case of JavaScript, the client is the browser.
 A server-side language is one that runs on the
Web server. Examples: PHP, Python
 Interpreted on-the-fly by the client
 Each line is processed as it loads in the browser
4
JavaScript is not Java
 Completely different types of languages that
just happen to be similarly named
 JavaScript - programs are interpreted in the
browser
 Java - programs are compiled and can be run as
stand alone applications
5
Why JavaScript?
 It’s easier to learn than most programming
languages
 It allows you to make interactive Web pages
 It can be fun!
6
Including JavaScript in HTML
 Two ways to add JavaScript to Web pages
 Use the <script>…</script> tag
 Include the script in an external file -- more about
this later in the semester
 Initially, we will only use the <script>…</script>
tag
7
Hello, World!
 Typically, in any programming language, the
first example you learn displays “Hello,
World!”
 We are going to take a look at a Hello World
example and then examine all of its parts.
8
Hello World in JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Hello World Example</title>
</head>
<body>
<script type="text/javascript">
<!--
document.write("<h1>Hello, world!</h1>");
//-->
</script>
</body>
</html>
9
Hello World Screenshot
10
The <script>…</script> tag
 The code for the script is contained in the
<script>…</script> tag
<script type="text/javascript">
.
.
.
</script>
11
Hiding JavaScript from Older
Browsers
 Some older browsers do not support JavaScript
 We need to tell those browsers to ignore what is in the
<script> tag
<script type="text/javascript">
<!--
some JavaScript code
//-->
</script>
12
Displaying text
 The document.write() method writes a string
of text to the browser
<script type="text/javascript">
<!--
document.write("<h1>Hello, world!</h1>");
//-->
</script>
13
document.write()
document.write("<h1>Hello,world!</h1>");
Enclosed in quotes --
denotes a "string"
Ends in a semicolon
14
Comments in JavaScript
 Two types of comments
 Single line
 Uses two forward slashes (i.e. //)
 Multiple line
 Uses /* and */
15
Single Line Comment Example
<script type="text/javascript">
<!--
// This is my JavaScript comment
document.write("<h1>Hello!</h1>");
//-->
</script>
16
Multiple Line Comment
Example
<script type="text/javascript">
<!--
/* This is a multiple line comment.
* The star at the beginning of this line is optional.
* So is the star at the beginning of this line.
*/
document.write("<h1>Hello!</h1>");
//-->
</script>
17
Find the Bug!
<script type="text/javascript">
<!--
/* This is my JavaScript comment
* that spans more than 1 line.
*
document.write("<h1>Hello!</h1>");
//-->
</script>

More Related Content

PPT
JavaScript (1).pptdffdfvdfvfvfvfefwefedfe
sgg86953
 
PPT
javascript.ppt
MrsSChitradeviCommer
 
DOC
Java script by Act Academy
actanimation
 
PPT
JAVA SCRIPT
Go4Guru
 
DOCX
Java script hello world
sanket kulkarni
 
PPTX
BEAAUTIFUL presentation of java
rana usman
 
DOCX
Javascript tutorial
Abhishek Kesharwani
 
PDF
Basic JavaScript Tutorial
DHTMLExtreme
 
JavaScript (1).pptdffdfvdfvfvfvfefwefedfe
sgg86953
 
javascript.ppt
MrsSChitradeviCommer
 
Java script by Act Academy
actanimation
 
JAVA SCRIPT
Go4Guru
 
Java script hello world
sanket kulkarni
 
BEAAUTIFUL presentation of java
rana usman
 
Javascript tutorial
Abhishek Kesharwani
 
Basic JavaScript Tutorial
DHTMLExtreme
 

Similar to L08IntroToJavaScript.ppt (20)

PDF
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
PPTX
CHAPTER 3 JS (1).pptx
achutachut
 
PDF
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
PDF
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
PPTX
JavaScript - Getting Started.pptx
JonnJorellPunto
 
PPTX
Unit 4 Java script.pptx
Gangesh8
 
DOC
Basics java scripts
ch samaram
 
PPT
Introduction to Java Scripting
fantasticdigitaltools
 
PPTX
Java script writing javascript
Jesus Obenita Jr.
 
DOCX
Javascript
Sushma M
 
PPTX
Java script Basic
Jaya Kumari
 
PPTX
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
DOC
2javascript web programming with JAVA script
umardanjumamaiwada
 
PDF
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
PDF
&lt;img src="../i/r_14.png" />
tutorialsruby
 
PDF
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
PDF
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
tutorialsruby
 
PPTX
JavaScript New Tutorial Class XI and XII.pptx
rish15r890
 
PPTX
HNDIT1022 Week 08, 09 10 Theory web .pptx
IsuriUmayangana
 
PPTX
Introduction to JavaScript
ApxicTechnologies1
 
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
CHAPTER 3 JS (1).pptx
achutachut
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
Bhavsingh Maloth
 
Web programming UNIT II by Bhavsingh Maloth
Bhavsingh Maloth
 
JavaScript - Getting Started.pptx
JonnJorellPunto
 
Unit 4 Java script.pptx
Gangesh8
 
Basics java scripts
ch samaram
 
Introduction to Java Scripting
fantasticdigitaltools
 
Java script writing javascript
Jesus Obenita Jr.
 
Javascript
Sushma M
 
Java script Basic
Jaya Kumari
 
JavaScript Core fundamentals - Learn JavaScript Here
Laurence Svekis ✔
 
2javascript web programming with JAVA script
umardanjumamaiwada
 
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
&lt;img src="../i/r_14.png" />
tutorialsruby
 
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
tutorialsruby
 
JavaScript New Tutorial Class XI and XII.pptx
rish15r890
 
HNDIT1022 Week 08, 09 10 Theory web .pptx
IsuriUmayangana
 
Introduction to JavaScript
ApxicTechnologies1
 
Ad

Recently uploaded (20)

PDF
Shreyas_Phanse_Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
SHREYAS PHANSE
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
PDF
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
DOCX
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Software Development Company | KodekX
KodekX
 
Shreyas_Phanse_Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
SHREYAS PHANSE
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Software Development Methodologies in 2025
KodekX
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Top AI API Alternatives to OpenAI: A Side-by-Side Breakdown
vilush
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Software Development Company | KodekX
KodekX
 
Ad

L08IntroToJavaScript.ppt

  • 2. 2 Topics  What is JavaScript?  Why JavaScript?  Including JavaScript in HTML  Hello World Example Script  JavaScript Comments
  • 3. 3 What is JavaScript?  Created by Netscape  Originally called LiveWire then LiveScript  A client-side scripting language  Client-side refers to the fact that it is executed in the client (software) that the viewer is using. In the case of JavaScript, the client is the browser.  A server-side language is one that runs on the Web server. Examples: PHP, Python  Interpreted on-the-fly by the client  Each line is processed as it loads in the browser
  • 4. 4 JavaScript is not Java  Completely different types of languages that just happen to be similarly named  JavaScript - programs are interpreted in the browser  Java - programs are compiled and can be run as stand alone applications
  • 5. 5 Why JavaScript?  It’s easier to learn than most programming languages  It allows you to make interactive Web pages  It can be fun!
  • 6. 6 Including JavaScript in HTML  Two ways to add JavaScript to Web pages  Use the <script>…</script> tag  Include the script in an external file -- more about this later in the semester  Initially, we will only use the <script>…</script> tag
  • 7. 7 Hello, World!  Typically, in any programming language, the first example you learn displays “Hello, World!”  We are going to take a look at a Hello World example and then examine all of its parts.
  • 8. 8 Hello World in JavaScript <!DOCTYPE html> <html> <head> <title>Hello World Example</title> </head> <body> <script type="text/javascript"> <!-- document.write("<h1>Hello, world!</h1>"); //--> </script> </body> </html>
  • 10. 10 The <script>…</script> tag  The code for the script is contained in the <script>…</script> tag <script type="text/javascript"> . . . </script>
  • 11. 11 Hiding JavaScript from Older Browsers  Some older browsers do not support JavaScript  We need to tell those browsers to ignore what is in the <script> tag <script type="text/javascript"> <!-- some JavaScript code //--> </script>
  • 12. 12 Displaying text  The document.write() method writes a string of text to the browser <script type="text/javascript"> <!-- document.write("<h1>Hello, world!</h1>"); //--> </script>
  • 14. 14 Comments in JavaScript  Two types of comments  Single line  Uses two forward slashes (i.e. //)  Multiple line  Uses /* and */
  • 15. 15 Single Line Comment Example <script type="text/javascript"> <!-- // This is my JavaScript comment document.write("<h1>Hello!</h1>"); //--> </script>
  • 16. 16 Multiple Line Comment Example <script type="text/javascript"> <!-- /* This is a multiple line comment. * The star at the beginning of this line is optional. * So is the star at the beginning of this line. */ document.write("<h1>Hello!</h1>"); //--> </script>
  • 17. 17 Find the Bug! <script type="text/javascript"> <!-- /* This is my JavaScript comment * that spans more than 1 line. * document.write("<h1>Hello!</h1>"); //--> </script>