SlideShare a Scribd company logo
1 of 38
PRESENTED BY-
AMBUJ
COLLEGE OF TECHNOLOGY
G.B.P.U.&T. PANTNAGAR
UTTARAKHAND
 Javascript is a dynamic computer
programming language. It is lightweight and
most commonly used as a part of web pages,
whose implementations allow client-side
script to interact with the user and make
dynamic pages. It is an interpreted
programming language with object-oriented
capabilities.
 The merits of using JavaScript are:
 Less server interaction: You can validate user input
before sending the page off to the server. This saves server
traffic, which means less load on your server.
 Immediate feedback to the visitors: They don't have to
wait for a page reload to see if they have forgotten to enter
something.
 Increased interactivity: You can create interfaces that
react when the user hovers over them with a mouse or
activates them via the keyboard.
 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.
NO!
Java and JavaScript are two
completely different languages in
both concept and design!
Java (developed by Sun
Microsystems) is a powerful and
much more complex programming
language - in the same category as C
and C++.
 We cannot treat JavaScript as a full-fledged programming
language. It lacks the following important features:
 Client-side JavaScript does not allow the reading or writing
of files. This has been kept for security reason.
 JavaScript cannot be used for networking applications
because there is no such support available.
 JavaScript doesn't have any multithreading or
multiprocessor capabilities.
 Once again, JavaScript is a lightweight, interpreted
programming language that allows you to build
interactivity into otherwise static HTML pages.
 JavaScript can be implemented using JavaScript
statements that are placed within the
<script>... </script> HTML tags in a web page.
 You can place the <script> tags, containing your
JavaScript, anywhere within you web page, but
it is normally recommended that you should
keep it within the <head> tags.
 The <script> tag alerts the browser program to
start interpreting all the text between these
tags as a script.
<script language="javascript" type="text/javascript">
JavaScript code
</script>
 The script tag takes two important attributes:
 Language: This attribute specifies what scripting
language you are using. Typically, its value will
be javascript. Although recent versions of HTML
(and XHTML, its successor) have phased out the
use of this attribute.
 Type: This attribute is what is now
recommended to indicate the scripting language
in use and its value should be set to
"text/javascript".
 So your JavaScript syntax will look as follows.
 The comment ends with a "//-- >". Here "//" signifies a
comment in JavaScript, so we add that to prevent a
browser from reading the end of the HTML comment as a
piece of JavaScript code. Next, we call a function
document.write which writes a string into our HTML
document.
<html>
<body>
<script language="javascript"
type="text/javascript">
< document.write ("Hello World!")
//-->
</script>
</body>
</html>
OUTPUT-
Hello World!
 Semicolons are Optional
 Simple statements in JavaScript are generally
followed by a semicolon character, just as they
are in C, C++, and Java. JavaScript, however,
allows you to omit this semicolon if each of your
statements are placed on a separate line.
 But when formatted in a single line as follows,
you must use semicolons:
 Case Sensitivity
 JavaScript is a case-sensitive language. This
means that the language keywords, variables,
function names, and any other identifiers must
always be typed with a consistent capitalization
of letters.
 So the identifiers Time and TIME will convey
different meanings in JavaScript.
 All the modern browsers come with built-in support for
JavaScript. Frequently, you may need to enable or disable
this support manually. This chapter explains the procedure
of enabling and disabling JavaScript support in your
browsers: Internet Explorer, Firefox, chrome, and Opera.
 JavaScript in Internet Explorer
 Here are the steps to turn on or turn off JavaScript in
Internet Explorer:
 Follow Tools -> Internet Options from the menu.
 Select Security tab from the dialog box.
 Click the Custom Level button.
 Scroll down till you find the Scripting option.
 Select Enable radio button under Active scripting.
 Finally click OK and come out.
 To disable JavaScript support in your Internet Explorer,
you need to select Disable radio button under Active
scripting.
 JavaScript Datatypes
 One of the most fundamental characteristics
of a programming language is the set of data
types it supports. These are the type of
values that can be represented and
manipulated in a programming language.
 JavaScript allows you to work with three
primitive data types:
 Numbers, e.g., 123, 120.50 etc.
 Strings of text, e.g. "This text string" etc.
 Boolean, e.g. true or false.
 JavaScript Variable Names
 While naming your variables in JavaScript, keep
the following rules in mind.
 You should not use any of the JavaScript
reserved keywords as a variable name. These
keywords are mentioned in the next section. For
example, break or boolean variable names are
not valid.
 JavaScript variable names should not start with a
numeral (0-9). They must begin with a letter or
an underscore character. For example, 123test
is an invalid variable name but _123test is a
valid one.
 JavaScript variable names are case-sensitive. For
example, Name and name are two different
variables.
<script type="text/javascript">
<
var name = "Ali";
var money;
money = 2000.50;
//-->
</script>
 A list of all the reserved words in JavaScript
are given in the following table. They cannot
be used as JavaScript variables, functions,
methods, loop labels, or any object names.
 What is an Operator?
 Let us take a simple expression 4 + 5 is
equal to 9. Here 4 and 5 are called operands
and ‘+’ is called the operator. JavaScript
supports the following types of operators.
 Arithmetic Operators
 Comparison Operators
 Logical (or Relational) Operators
 Assignment Operators
 Conditional (or ternary) Operators
Arithmetic Operators
Operator Description Example Result
+ Addition x=2 4
y=2
x+y
- Subtraction x=5 3
y=2
x-y
* Multiplication x=5 20
y=4
x*y
/ Division 15/5 3
5/2 2,5
% Modulus (division remainder) 5%2 1
10%8 2
10%2 0
++ Increment x=5 x=6
x++
-- Decrement x=5 x=4
x--
Assignment OperatorsOperator Example Is The Same As
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
%= x%=y x=x%y
(Karşılaştırma işleci, iki ya da daha
çok değeri birbiriyle
karşılaştırarak True ya da False
olarak mantıksal bir değer
döndürür.)
Operator Description Example
== is equal to 5==8 returns false
=== is equal to (checks for both value and type) x=5
y="5"
x==y returns true
x===y returns false
!= is not equal 5!=8 returns true
> is greater than 5>8 returns false
< is less than 5<8 returns true
>= is greater than or equal to 5>=8 returns false
<= is less than or equal to 5<=8 returns true
Logical Operators
(İkili işleçler birden çok
karşılaştırma işlemini tek bir
koşul ifadesi olarak
birleştirirler.)
Operator Description Example
&& and x=6
y=3
(x < 10 && y > 1) returns true
|| or x=6
y=3
(x==5 || y==5) returns false
! not x=6
y=3
!(x==y) returns true
<html>
<body>
<script type="text/javascript">
<
var age = 20;
if( age > 18 ){
document.write("<b>Qualifies for driving</b>");
}
//-->
</script>
<p>Set the variable to different value and then try...</p>
</body>
</html>
Output
Qualifies for driving
Set the variable to different value and then try...
<html>
<body>
<script type="text/javascript">
<
var grade='A';
document.write("Entering switch block<br />");
switch (grade)
{
case 'A': document.write("Good job<br />");
break;
case 'B': document.write("Pretty good<br />"); break;
case 'C': document.write("Passed<br />"); break;
case 'D': document.write("Not so good<br />"); break;
case 'F': document.write("Failed<br />"); break;
default:document.write("Unknown grade<br />")
}
document.write("Exiting switch block");
//-->
</script>
<p>Set the variable to different value and then try...</p>
</body>
</html>
Output
Entering switch block
Good job
Exiting switch block
Set the variable to different value and then try...
<html>
<body>
<script type="text/javascript">
<
var count;
document.write("Starting Loop" + "<br />");
for(count = 0; count < 10; count++){
document.write("Current Count : " + count );
document.write("<br />");
}
document.write("Loop stopped!");
//-->
</script>
<p>Set the variable to different value and then try...</p>
</body>
</html>
Starting Loop
Current Count : 0
Current Count : 1
Current Count : 2
Current Count : 3
Current Count : 4
Current Count : 5
Current Count : 6
Current Count : 7
Current Count : 8
Current Count : 9
Loop stopped!
Set the variable to different value and then try...
 A function is a group of reusable code which
can be called anywhere in your program. This
eliminates the need of writing the same code
again and again. It helps programmers in
writing modular codes. Functions allow a
programmer to divide a big program into a
number of small and manageable functions.
 Like any other advanced programming
language, JavaScript also supports all the
features necessary to write modular code
using functions.
 Before we use a function, we need to define
it. The most common way to define a
function in JavaScript is by using the
function keyword, followed by a unique
function name, a list of parameters (that
might be empty), and a statement block
surrounded by curly braces.
<html>
<head>
<script type="text/javascript">
function sayHello(name, age)
{
document.write (name + " is " + age + " years old.");
}
</script>
</head>
<body>
<p>Click the following button to call the function</p> <form>
<input type="button" onclick="sayHello('Zara', 7)" value="Say
Hello"> </form>
<p>Use different parameters inside the function and then
try...</p>
</body>
</html>
 Alert Box
 An alert box is often used if you want to make
sure information comes through to the user.
 When an alert box pops up, the user will have to
click "OK" to proceed.
<script>
alert("Hello World!")
</script>
 Confirm Box
 A confirm box is often used if you want the user
to verify or accept something.
 When a confirm box pops up, the user will have
to click either "OK" or "Cancel" to proceed.
 If the user clicks "OK", the box returns true. If
the user clicks "Cancel", the box returns false.
 Prompt Box
 A prompt box is often used if you want the user
to input a value before entering a page.
 When a prompt box pops up, the user will have
to click either "OK" or "Cancel" to proceed after
entering an input value.
 If the user clicks "OK“, the box returns the input
value. If the user clicks "Cancel“, the box returns
null.
Introduction to Javascript
Introduction to Javascript
Introduction to Javascript

More Related Content

What's hot (20)

Div tag presentation
Div tag presentationDiv tag presentation
Div tag presentation
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Web Design (Tools)
Web Design (Tools)Web Design (Tools)
Web Design (Tools)
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Css3
Css3Css3
Css3
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
LINKING IN HTML
LINKING IN HTMLLINKING IN HTML
LINKING IN HTML
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Js ppt
Js pptJs ppt
Js ppt
 
HTML (Web) basics for a beginner
HTML (Web) basics for a beginnerHTML (Web) basics for a beginner
HTML (Web) basics for a beginner
 
Java script
Java scriptJava script
Java script
 
Web development tool
Web development toolWeb development tool
Web development tool
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overview
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Jquery
JqueryJquery
Jquery
 
CSS Lists and Tables
CSS Lists and TablesCSS Lists and Tables
CSS Lists and Tables
 

Similar to Introduction to Javascript

Similar to Introduction to Javascript (20)

Basics of Javascript
Basics of Javascript Basics of Javascript
Basics of Javascript
 
Java script
Java scriptJava script
Java script
 
Java scipt
Java sciptJava scipt
Java scipt
 
Javascript
JavascriptJavascript
Javascript
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Javascript tutorial basic for starter
Javascript tutorial basic for starterJavascript tutorial basic for starter
Javascript tutorial basic for starter
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
 
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 tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
Java script.pptx v
Java script.pptx                                     vJava script.pptx                                     v
Java script.pptx v
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
 
Javascript
JavascriptJavascript
Javascript
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptx
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptx
 
Web programming
Web programmingWeb programming
Web programming
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
 
JavaScript_III.pptx
JavaScript_III.pptxJavaScript_III.pptx
JavaScript_III.pptx
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
 

Recently uploaded

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
(TARA) Talegaon Dabhade Call Girls Just Call 7001035870 [ Cash on Delivery ] ...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 

Introduction to Javascript

  • 1. PRESENTED BY- AMBUJ COLLEGE OF TECHNOLOGY G.B.P.U.&T. PANTNAGAR UTTARAKHAND
  • 2.  Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities.
  • 3.  The merits of using JavaScript are:  Less server interaction: You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.  Immediate feedback to the visitors: They don't have to wait for a page reload to see if they have forgotten to enter something.  Increased interactivity: You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.  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.
  • 4. NO! Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.
  • 5.
  • 6.  We cannot treat JavaScript as a full-fledged programming language. It lacks the following important features:  Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reason.  JavaScript cannot be used for networking applications because there is no such support available.  JavaScript doesn't have any multithreading or multiprocessor capabilities.  Once again, JavaScript is a lightweight, interpreted programming language that allows you to build interactivity into otherwise static HTML pages.
  • 7.  JavaScript can be implemented using JavaScript statements that are placed within the <script>... </script> HTML tags in a web page.  You can place the <script> tags, containing your JavaScript, anywhere within you web page, but it is normally recommended that you should keep it within the <head> tags.  The <script> tag alerts the browser program to start interpreting all the text between these tags as a script.
  • 8. <script language="javascript" type="text/javascript"> JavaScript code </script>  The script tag takes two important attributes:  Language: This attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute.  Type: This attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript".  So your JavaScript syntax will look as follows.
  • 9.  The comment ends with a "//-- >". Here "//" signifies a comment in JavaScript, so we add that to prevent a browser from reading the end of the HTML comment as a piece of JavaScript code. Next, we call a function document.write which writes a string into our HTML document. <html> <body> <script language="javascript" type="text/javascript"> < document.write ("Hello World!") //--> </script> </body> </html> OUTPUT- Hello World!
  • 10.  Semicolons are Optional  Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements are placed on a separate line.  But when formatted in a single line as follows, you must use semicolons:  Case Sensitivity  JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed with a consistent capitalization of letters.  So the identifiers Time and TIME will convey different meanings in JavaScript.
  • 11.  All the modern browsers come with built-in support for JavaScript. Frequently, you may need to enable or disable this support manually. This chapter explains the procedure of enabling and disabling JavaScript support in your browsers: Internet Explorer, Firefox, chrome, and Opera.  JavaScript in Internet Explorer  Here are the steps to turn on or turn off JavaScript in Internet Explorer:  Follow Tools -> Internet Options from the menu.  Select Security tab from the dialog box.  Click the Custom Level button.  Scroll down till you find the Scripting option.  Select Enable radio button under Active scripting.  Finally click OK and come out.  To disable JavaScript support in your Internet Explorer, you need to select Disable radio button under Active scripting.
  • 12.  JavaScript Datatypes  One of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language.  JavaScript allows you to work with three primitive data types:  Numbers, e.g., 123, 120.50 etc.  Strings of text, e.g. "This text string" etc.  Boolean, e.g. true or false.
  • 13.  JavaScript Variable Names  While naming your variables in JavaScript, keep the following rules in mind.  You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.  JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or an underscore character. For example, 123test is an invalid variable name but _123test is a valid one.  JavaScript variable names are case-sensitive. For example, Name and name are two different variables.
  • 14. <script type="text/javascript"> < var name = "Ali"; var money; money = 2000.50; //--> </script>
  • 15.  A list of all the reserved words in JavaScript are given in the following table. They cannot be used as JavaScript variables, functions, methods, loop labels, or any object names.
  • 16.
  • 17.  What is an Operator?  Let us take a simple expression 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator. JavaScript supports the following types of operators.  Arithmetic Operators  Comparison Operators  Logical (or Relational) Operators  Assignment Operators  Conditional (or ternary) Operators
  • 18. Arithmetic Operators Operator Description Example Result + Addition x=2 4 y=2 x+y - Subtraction x=5 3 y=2 x-y * Multiplication x=5 20 y=4 x*y / Division 15/5 3 5/2 2,5 % Modulus (division remainder) 5%2 1 10%8 2 10%2 0 ++ Increment x=5 x=6 x++ -- Decrement x=5 x=4 x--
  • 19. Assignment OperatorsOperator Example Is The Same As = x=y x=y += x+=y x=x+y -= x-=y x=x-y *= x*=y x=x*y /= x/=y x=x/y %= x%=y x=x%y
  • 20. (Karşılaştırma işleci, iki ya da daha çok değeri birbiriyle karşılaştırarak True ya da False olarak mantıksal bir değer döndürür.) Operator Description Example == is equal to 5==8 returns false === is equal to (checks for both value and type) x=5 y="5" x==y returns true x===y returns false != is not equal 5!=8 returns true > is greater than 5>8 returns false < is less than 5<8 returns true >= is greater than or equal to 5>=8 returns false <= is less than or equal to 5<=8 returns true
  • 21. Logical Operators (İkili işleçler birden çok karşılaştırma işlemini tek bir koşul ifadesi olarak birleştirirler.) Operator Description Example && and x=6 y=3 (x < 10 && y > 1) returns true || or x=6 y=3 (x==5 || y==5) returns false ! not x=6 y=3 !(x==y) returns true
  • 22. <html> <body> <script type="text/javascript"> < var age = 20; if( age > 18 ){ document.write("<b>Qualifies for driving</b>"); } //--> </script> <p>Set the variable to different value and then try...</p> </body> </html> Output Qualifies for driving Set the variable to different value and then try...
  • 23. <html> <body> <script type="text/javascript"> < var grade='A'; document.write("Entering switch block<br />"); switch (grade) { case 'A': document.write("Good job<br />"); break; case 'B': document.write("Pretty good<br />"); break; case 'C': document.write("Passed<br />"); break; case 'D': document.write("Not so good<br />"); break; case 'F': document.write("Failed<br />"); break; default:document.write("Unknown grade<br />") } document.write("Exiting switch block"); //--> </script> <p>Set the variable to different value and then try...</p> </body> </html>
  • 24. Output Entering switch block Good job Exiting switch block Set the variable to different value and then try...
  • 25. <html> <body> <script type="text/javascript"> < var count; document.write("Starting Loop" + "<br />"); for(count = 0; count < 10; count++){ document.write("Current Count : " + count ); document.write("<br />"); } document.write("Loop stopped!"); //--> </script> <p>Set the variable to different value and then try...</p> </body> </html>
  • 26. Starting Loop Current Count : 0 Current Count : 1 Current Count : 2 Current Count : 3 Current Count : 4 Current Count : 5 Current Count : 6 Current Count : 7 Current Count : 8 Current Count : 9 Loop stopped! Set the variable to different value and then try...
  • 27.  A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code again and again. It helps programmers in writing modular codes. Functions allow a programmer to divide a big program into a number of small and manageable functions.  Like any other advanced programming language, JavaScript also supports all the features necessary to write modular code using functions.
  • 28.  Before we use a function, we need to define it. The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.
  • 29. <html> <head> <script type="text/javascript"> function sayHello(name, age) { document.write (name + " is " + age + " years old."); } </script> </head> <body> <p>Click the following button to call the function</p> <form> <input type="button" onclick="sayHello('Zara', 7)" value="Say Hello"> </form> <p>Use different parameters inside the function and then try...</p> </body> </html>
  • 30.
  • 31.  Alert Box  An alert box is often used if you want to make sure information comes through to the user.  When an alert box pops up, the user will have to click "OK" to proceed. <script> alert("Hello World!") </script>
  • 32.  Confirm Box  A confirm box is often used if you want the user to verify or accept something.  When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.  If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
  • 33.
  • 34.
  • 35.  Prompt Box  A prompt box is often used if you want the user to input a value before entering a page.  When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.  If the user clicks "OK“, the box returns the input value. If the user clicks "Cancel“, the box returns null.