Basic JavaScript
What is JS?
 JavaScript is the programming language of HTML
and the Web.
Introduction
 Its Free and (NO) need engine
 Simple and Easy to learn
 Lightweight and Fast to code
 Front & Back side coverage
 Third party library
 Growth community and docs
JS General format
<html>
<head>
<title>Hello World in JavaScript</title>
</head>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>
Where Did you Put your
Scripts
 You can have any number of scripts
 Scripts can be placed in the HEAD or in the BODY
 In the HEAD, scripts are run before the page is
displayed
 In the BODY, scripts are run as the page is
displayed
 In the HEAD is the right place to define functions
and variables that are used by scripts within the
BODY
JavaScript Variables
 JavaScript has variables that you can declare
with the optional var keyword
 Variables declared within a function are local to
that function
 Variables declared outside of any function are
global variables
var myname = “vithu";
JavaScript Operators and
Constructs
 JavaScript has most of the operators we're used
to from C/Java
– Arithmetic (+, - , *, /, %)
– Assignment (=, +=, -=, *= /=, %=, ++, --)
– Logical (&&, ||, !)
– Comparison (<, >, <=, >=, ==)
Note: + also does string concatenation
 Constructs:
– if, else, while, for, switch, case
Simple User Interaction
 There are three built-in methods of doing simple
user interaction
 alert("There's a monster on the wing!");
o Alert something
 confirm("Are you sure you want to do that?");
o Asks the user to confirm
 prompt("Enter you name", "Adam");
o Asks the user something
JavaScript Functions
 JavaScript lets you define functions using the
function keyword
 Functions can return values using the return
keyword
function showConfirm()
{
confirm("Are you sure you want to do that?");
}
JavaScript Arrays
 JavaScript has arrays that are indexed starting at
0
 Special version of for works with arrays
 <script type="text/javascript">
 var colors = new Array();
 colors[0] = "red"; colors[1] = "green";
 colors[2] = "blue"; colors[3] = "orange";
 colors[4] = "magenta"; colors[5] = "cyan";
 for (var i in colors) {
 document.write("<div style="background-color:"
 + colors[i] + ";">"
 + colors[i] + "</div>n");
 }
 </script>
JavaScript Events
 Common Events:
– onload and onunload : when a page is first visited or
left
– onfocus, onblur, onchange : events pertaining to form
elements
– onsubmit : when a form is submitted
– onmouseover, onmouseout : for "menu effects"
Exception Handling
 JavaScript also has try, catch, and throw
keywords for handling JavaScript errors
try {
runSomeCode();
}
catch(err) {
var txt="There was an error on this page.nn"
+ "Error description: "
+ err.description + "nn"
alert(txt)
}
Comments in JavaScript
 Comments in JavaScript are delimited with // and
/* */ as in Java and C++
References
 http://cglab.ca/~morin/teaching/2405/notes/javasc
ript1.pdf
 www.w3schools.com/js/default.asp

More Related Content

PPTX
Introduction to Java Script
PPTX
1. java script language fundamentals
PPTX
Java script
PPT
Java script
PPTX
Java Script
PPTX
Java script writing javascript
PPT
Java script
PDF
Intro to jquery
Introduction to Java Script
1. java script language fundamentals
Java script
Java script
Java Script
Java script writing javascript
Java script
Intro to jquery

What's hot (20)

PDF
Javascript
PPTX
Javascript
PPTX
Java Script An Introduction By HWA
PPT
Java script Learn Easy
PPTX
JavaScript Introduction and Implementation
PPTX
Using shortcode in plugin development
PPTX
Js placement
PPT
Java script
ODP
Coder Presentation
PPT
Begin scripting
PDF
React.js触ってみた 吉澤和香奈
DOCX
programming
DOCX
Javascript tutorial
PPT
Html JavaScript and CSS
PPT
Javascript by geetanjali
PPTX
Haml in 5 minutes
PPTX
Ch2(working with forms)
PPTX
Java script Session No 1
PPT
JavaScript - Part-1
PDF
Rethink Frontend Development With Elm
Javascript
Javascript
Java Script An Introduction By HWA
Java script Learn Easy
JavaScript Introduction and Implementation
Using shortcode in plugin development
Js placement
Java script
Coder Presentation
Begin scripting
React.js触ってみた 吉澤和香奈
programming
Javascript tutorial
Html JavaScript and CSS
Javascript by geetanjali
Haml in 5 minutes
Ch2(working with forms)
Java script Session No 1
JavaScript - Part-1
Rethink Frontend Development With Elm
Ad

Viewers also liked (20)

PDF
Java script introducation & basics
 
PPTX
javascript3
PDF
[Basic HTML/CSS] 6. css - box sizing, display, margin, padding
PDF
[CSS Drawing] Basic Tutorial (라이언 그리기)
PDF
PROGRESS - CSS BASIC
PDF
[Basic HTML/CSS] 7. project
PPTX
Web engineering - HTML Form
PDF
HTML Dasar : #10 Form
PDF
[Basic HTML/CSS] 4. html - form tags
PDF
[Basic HTML/CSS] 3. html - table tags
PDF
Basic css-tutorial
PPT
Basic css
PPTX
Java script basics
PPTX
Python basic
PPT
C++ to java
PPT
Dot net guide for beginner
PPTX
C sharp
PPTX
Beginning Java for .NET developers
Java script introducation & basics
 
javascript3
[Basic HTML/CSS] 6. css - box sizing, display, margin, padding
[CSS Drawing] Basic Tutorial (라이언 그리기)
PROGRESS - CSS BASIC
[Basic HTML/CSS] 7. project
Web engineering - HTML Form
HTML Dasar : #10 Form
[Basic HTML/CSS] 4. html - form tags
[Basic HTML/CSS] 3. html - table tags
Basic css-tutorial
Basic css
Java script basics
Python basic
C++ to java
Dot net guide for beginner
C sharp
Beginning Java for .NET developers
Ad

Similar to Java script basic (20)

PPTX
JavaScript_III.pptx
PPT
Presentation JavaScript Introduction Data Types Variables Control Structure
PPT
Java Script
PDF
Java Script
PPT
JavaScript ppt for introduction of javascripta
PPTX
gdscWorkShopJavascriptintroductions.pptx
PPTX
Unit 3-Javascript.pptx
PPTX
Javascript
PPTX
Java script
PPTX
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
PPTX
Java script
PPTX
Web designing unit 4
PDF
Basic JavaScript Tutorial
PDF
8.-Javascript-report powerpoint presentation
PPT
JavaScript - An Introduction
PPTX
Java script
PPTX
Java Script basics and DOM
PPTX
Java script
PPT
Js ppt
PDF
Basics of JavaScript
JavaScript_III.pptx
Presentation JavaScript Introduction Data Types Variables Control Structure
Java Script
Java Script
JavaScript ppt for introduction of javascripta
gdscWorkShopJavascriptintroductions.pptx
Unit 3-Javascript.pptx
Javascript
Java script
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
Java script
Web designing unit 4
Basic JavaScript Tutorial
8.-Javascript-report powerpoint presentation
JavaScript - An Introduction
Java script
Java Script basics and DOM
Java script
Js ppt
Basics of JavaScript

Recently uploaded (20)

PPTX
"Secure File Sharing Solutions on AWS".pptx
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Practical Indispensable Project Management Tips for Delivering Successful Exp...
PPTX
Download Adobe Photoshop Crack 2025 Free
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
AI Guide for Business Growth - Arna Softech
PDF
Microsoft Office 365 Crack Download Free
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
most interesting chapter in the world ppt
PPTX
Introduction to Windows Operating System
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
Matchmaking for JVMs: How to Pick the Perfect GC Partner
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
"Secure File Sharing Solutions on AWS".pptx
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
iTop VPN Crack Latest Version Full Key 2025
Practical Indispensable Project Management Tips for Delivering Successful Exp...
Download Adobe Photoshop Crack 2025 Free
GSA Content Generator Crack (2025 Latest)
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
AI Guide for Business Growth - Arna Softech
Microsoft Office 365 Crack Download Free
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
most interesting chapter in the world ppt
Introduction to Windows Operating System
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
Full-Stack Developer Courses That Actually Land You Jobs
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
MCP Security Tutorial - Beginner to Advanced
Matchmaking for JVMs: How to Pick the Perfect GC Partner
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Wondershare Recoverit Full Crack New Version (Latest 2025)

Java script basic

  • 2. What is JS?  JavaScript is the programming language of HTML and the Web.
  • 3. Introduction  Its Free and (NO) need engine  Simple and Easy to learn  Lightweight and Fast to code  Front & Back side coverage  Third party library  Growth community and docs
  • 4. JS General format <html> <head> <title>Hello World in JavaScript</title> </head> <body> <script type="text/javascript"> document.write("Hello World!"); </script> </body> </html>
  • 5. Where Did you Put your Scripts  You can have any number of scripts  Scripts can be placed in the HEAD or in the BODY  In the HEAD, scripts are run before the page is displayed  In the BODY, scripts are run as the page is displayed  In the HEAD is the right place to define functions and variables that are used by scripts within the BODY
  • 6. JavaScript Variables  JavaScript has variables that you can declare with the optional var keyword  Variables declared within a function are local to that function  Variables declared outside of any function are global variables var myname = “vithu";
  • 7. JavaScript Operators and Constructs  JavaScript has most of the operators we're used to from C/Java – Arithmetic (+, - , *, /, %) – Assignment (=, +=, -=, *= /=, %=, ++, --) – Logical (&&, ||, !) – Comparison (<, >, <=, >=, ==) Note: + also does string concatenation  Constructs: – if, else, while, for, switch, case
  • 8. Simple User Interaction  There are three built-in methods of doing simple user interaction  alert("There's a monster on the wing!"); o Alert something  confirm("Are you sure you want to do that?"); o Asks the user to confirm  prompt("Enter you name", "Adam"); o Asks the user something
  • 9. JavaScript Functions  JavaScript lets you define functions using the function keyword  Functions can return values using the return keyword function showConfirm() { confirm("Are you sure you want to do that?"); }
  • 10. JavaScript Arrays  JavaScript has arrays that are indexed starting at 0  Special version of for works with arrays
  • 11.  <script type="text/javascript">  var colors = new Array();  colors[0] = "red"; colors[1] = "green";  colors[2] = "blue"; colors[3] = "orange";  colors[4] = "magenta"; colors[5] = "cyan";  for (var i in colors) {  document.write("<div style="background-color:"  + colors[i] + ";">"  + colors[i] + "</div>n");  }  </script>
  • 12. JavaScript Events  Common Events: – onload and onunload : when a page is first visited or left – onfocus, onblur, onchange : events pertaining to form elements – onsubmit : when a form is submitted – onmouseover, onmouseout : for "menu effects"
  • 13. Exception Handling  JavaScript also has try, catch, and throw keywords for handling JavaScript errors try { runSomeCode(); } catch(err) { var txt="There was an error on this page.nn" + "Error description: " + err.description + "nn" alert(txt) }
  • 14. Comments in JavaScript  Comments in JavaScript are delimited with // and /* */ as in Java and C++