SlideShare una empresa de Scribd logo
JavaScript Basics
Let’s Start
1. JavaScript is the programming language of the Web.
2. JavaScript is easy to learn
3. JavaScript is the world’s most popular programming Language
Overview
Alert Box in JavaScript
An alert box is used if you want to make sure information comes though to the user.
When an alert box pops up, the user will have to click “OK” .
Syntax:
window.alert(“Text”)
A confirm box is used if we want the user to verify or accept something
When a confirm box pops up, the user will click on “OK” or “Cancel”.
It works on true or false depends on “OK” and “Cancel”.
Syntax:
window.confirm(“Text”)
confirm Box in JavaScript
A Prompt box is used if we want the user to input a value before entering a page.
When a prompt box pops up, the user will have to click on “OK” or “Cancel” to proceed after
entering an input value.
“OK” returns the input value.
“Cancel” returns null
Syntax:
window.prompt(“Text”)
Prompt Box in JavaScript
In JavaScript expression is a valid set of literals , variables , operators that evaluate to a single
value that is an expression.
var x;
let y;
x=8;
y=9;
Let z=x+y;
Fixed values are called as Literals.
Expression in JavaScript
• Arithmetic Operators
• Comparison (Relational) Operators
• Bitwise Operators
• Logical Operators
• Assignment Operators
• Special Operators
Operators in JavaScript
Operator Description Example
+ Addition 10+20 = 30
- Subtraction 20-10 = 10
* Multiplication 10*20 = 200
/ Division 20/10 = 2
% Modulus (Remainder) 20%10 = 0
++ Increment var a=10; a++; Now a = 11
-- Decrement var a=10; a--; Now a = 9
Arithmetic Operators
Comparison Operators
Operator Description Example
== Is equal to 10==20 = false
=== Identical (equal and of same
type)
10==20 = false
!= Not equal to 10!=20 = true
!== Not Identical 20!==20 = false
> Greater than 20>10 = true
>= Greater than or equal to 20>=10 = true
< Less than 20<10 = false
<= Less than or equal to 20<=10 = false
Bitwise Operators
Operator Description Example
& Bitwise AND (10==20 & 20==33) = false
| Bitwise OR (10==20 | 20==33) = false
^ Bitwise XOR (10==20 ^ 20==33) = false
~ Bitwise NOT (~10) = -10
<< Bitwise Left Shift (10<<2) = 40
>> Bitwise Right Shift (10>>2) = 2
>>> Bitwise Right Shift with Zero (10>>>2) = 2
Comparison Operators
Operator Description Example
== Is equal to 10==20 = false
=== Identical (equal and of same
type)
10==20 = false
!= Not equal to 10!=20 = true
!== Not Identical 20!==20 = false
> Greater than 20>10 = true
>= Greater than or equal to 20>=10 = true
< Less than 20<10 = false
<= Less than or equal to 20<=10 = false
Logical Operators
Operator Description Example
&& Logical AND (10==20 && 20==33) = false
|| Logical OR (10==20 || 20==33) = false
! Logical Not !(10==20) = true
Assignment Operators
Operator Description Example
= Assign 10+10 = 20
+= Add and assign var a=10; a+=20; Now a =
30
-= Subtract and assign var a=20; a-=10; Now a = 10
*= Multiply and assign var a=10; a*=20; Now a =
200
/= Divide and assign var a=10; a/=2; Now a = 5
%= Modulus and assign var a=10; a%=2; Now a = 0
Special Operators
Operator Description
(?:) Conditional Operator returns value based on
the condition. It is like if-else.
, Comma Operator allows multiple expressions
to be evaluated as single statement.
delete Delete Operator deletes a property from the
object.
in In Operator checks if object has the given
property
instanceof checks if the object is an instance of given
type
new creates an instance (object)
typeof checks the type of object.
void it discards the expression's return value.
yield checks what is returned in a generator by the
Printing basic outputs
In JavaScript we can display data in following ways:
• Writing into an HTML element, using innerHTML.
• Writing into the HTML output using document.write().
• Writing into an alert box, using window.alert().
• Writing into the browser console, using console.log().
Adavntages of JavaScripts
• Speed
• Simplicity
• Popularity
• Interoperability
• Server Load
• Rich Interfaces
• Extended Functionality
• Versatility
• Less Overhead

Más contenido relacionado

Similar a Introduction to JavaScript Scripting Language

ViewController.swift Calculatorimport Cocoaimport UIKit.pdf
 ViewController.swift Calculatorimport Cocoaimport UIKit.pdf ViewController.swift Calculatorimport Cocoaimport UIKit.pdf
ViewController.swift Calculatorimport Cocoaimport UIKit.pdf
arasanlethers
 
2.overview of c#
2.overview of c#2.overview of c#
2.overview of c#
Raghu nath
 

Similar a Introduction to JavaScript Scripting Language (20)

Computer programming 2 Lesson 7
Computer programming 2  Lesson 7Computer programming 2  Lesson 7
Computer programming 2 Lesson 7
 
Ch4
Ch4Ch4
Ch4
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
ViewController.swift Calculatorimport Cocoaimport UIKit.pdf
 ViewController.swift Calculatorimport Cocoaimport UIKit.pdf ViewController.swift Calculatorimport Cocoaimport UIKit.pdf
ViewController.swift Calculatorimport Cocoaimport UIKit.pdf
 
2.overview of c#
2.overview of c#2.overview of c#
2.overview of c#
 
Vb script final pari
Vb script final pariVb script final pari
Vb script final pari
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
Operator 04 (js)
Operator 04 (js)Operator 04 (js)
Operator 04 (js)
 
Javascript
JavascriptJavascript
Javascript
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Javascript
JavascriptJavascript
Javascript
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
 

Último

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Último (20)

The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 

Introduction to JavaScript Scripting Language

  • 2. 1. JavaScript is the programming language of the Web. 2. JavaScript is easy to learn 3. JavaScript is the world’s most popular programming Language Overview
  • 3. Alert Box in JavaScript An alert box is used if you want to make sure information comes though to the user. When an alert box pops up, the user will have to click “OK” . Syntax: window.alert(“Text”)
  • 4. A confirm box is used if we want the user to verify or accept something When a confirm box pops up, the user will click on “OK” or “Cancel”. It works on true or false depends on “OK” and “Cancel”. Syntax: window.confirm(“Text”) confirm Box in JavaScript
  • 5. A Prompt box is used if we want the user to input a value before entering a page. When a prompt box pops up, the user will have to click on “OK” or “Cancel” to proceed after entering an input value. “OK” returns the input value. “Cancel” returns null Syntax: window.prompt(“Text”) Prompt Box in JavaScript
  • 6. In JavaScript expression is a valid set of literals , variables , operators that evaluate to a single value that is an expression. var x; let y; x=8; y=9; Let z=x+y; Fixed values are called as Literals. Expression in JavaScript
  • 7. • Arithmetic Operators • Comparison (Relational) Operators • Bitwise Operators • Logical Operators • Assignment Operators • Special Operators Operators in JavaScript
  • 8. Operator Description Example + Addition 10+20 = 30 - Subtraction 20-10 = 10 * Multiplication 10*20 = 200 / Division 20/10 = 2 % Modulus (Remainder) 20%10 = 0 ++ Increment var a=10; a++; Now a = 11 -- Decrement var a=10; a--; Now a = 9 Arithmetic Operators
  • 9. Comparison Operators Operator Description Example == Is equal to 10==20 = false === Identical (equal and of same type) 10==20 = false != Not equal to 10!=20 = true !== Not Identical 20!==20 = false > Greater than 20>10 = true >= Greater than or equal to 20>=10 = true < Less than 20<10 = false <= Less than or equal to 20<=10 = false
  • 10. Bitwise Operators Operator Description Example & Bitwise AND (10==20 & 20==33) = false | Bitwise OR (10==20 | 20==33) = false ^ Bitwise XOR (10==20 ^ 20==33) = false ~ Bitwise NOT (~10) = -10 << Bitwise Left Shift (10<<2) = 40 >> Bitwise Right Shift (10>>2) = 2 >>> Bitwise Right Shift with Zero (10>>>2) = 2
  • 11. Comparison Operators Operator Description Example == Is equal to 10==20 = false === Identical (equal and of same type) 10==20 = false != Not equal to 10!=20 = true !== Not Identical 20!==20 = false > Greater than 20>10 = true >= Greater than or equal to 20>=10 = true < Less than 20<10 = false <= Less than or equal to 20<=10 = false
  • 12. Logical Operators Operator Description Example && Logical AND (10==20 && 20==33) = false || Logical OR (10==20 || 20==33) = false ! Logical Not !(10==20) = true
  • 13. Assignment Operators Operator Description Example = Assign 10+10 = 20 += Add and assign var a=10; a+=20; Now a = 30 -= Subtract and assign var a=20; a-=10; Now a = 10 *= Multiply and assign var a=10; a*=20; Now a = 200 /= Divide and assign var a=10; a/=2; Now a = 5 %= Modulus and assign var a=10; a%=2; Now a = 0
  • 14. Special Operators Operator Description (?:) Conditional Operator returns value based on the condition. It is like if-else. , Comma Operator allows multiple expressions to be evaluated as single statement. delete Delete Operator deletes a property from the object. in In Operator checks if object has the given property instanceof checks if the object is an instance of given type new creates an instance (object) typeof checks the type of object. void it discards the expression's return value. yield checks what is returned in a generator by the
  • 15. Printing basic outputs In JavaScript we can display data in following ways: • Writing into an HTML element, using innerHTML. • Writing into the HTML output using document.write(). • Writing into an alert box, using window.alert(). • Writing into the browser console, using console.log().
  • 16. Adavntages of JavaScripts • Speed • Simplicity • Popularity • Interoperability • Server Load • Rich Interfaces • Extended Functionality • Versatility • Less Overhead