SlideShare a Scribd company logo
1 of 16
Download to read offline
JavaScript
A SNEAK PREVIEW PRESENTATION
</script>
Why we need JavaScript
• HTML to define the content of web pages
• CSS to specify the layout of web pages
• JavaScript to program the behavior of web pages
JavaScript is nice because
• Adds interactivity (event handling)
• Manipulates page contents dynamically
• Does real time validations
• No reloads – All is executed on browser
• Makes asynchronous server calls
• Performs calculations on the spot
• Controls Browser, Window, Keyboard, Mouse, Cookies..
• Can accept third party libraries
Where to place JavaScript
<html>
<body>
…
<script language="javascript" type="text/javascript">
…
</script>
</body>
</html>
<script type="text/javascript" src="filename.js" ></script>
Variables
• No declaration of types
• Name cannot start with numbers
• JavaScript is case sensitive
• myVariable is a different variable to myvariable
The semicolon at the end of the line is not
mandatory
var myVariable;
myVariable = 'Bob';
var myVariable = 'Bob';
myVariable = 'Steve';
Data Types
Variable Example
String var myVariable = 'Bob';
Number var myVariable = 10;
Boolean var myVariable = true;
Array
var myVariable = [1,'Bob','Steve',10];
Refer to each member of the array like this:
myVariable[0], myVariable[1], etc.
Object
var myVariable = document.querySelector('h1');
All of the above examples too.
Comments
/* Everything in between is a comment */
// This is also a comment
Operators
Operator Symbol(s) Example
add/concatenation +
6 + 9;
"Hello " + "world!";
subtract, multiply, divide -, *, /
9 - 3;
8 * 2;
9 / 3;
assignment operator = var myVariable = 'Bob';
Identity operator ===
var myVariable = 3;
myVariable === 4;
negation, not equal !, !==
var myVariable = 3;
myVariable !== 3;
Conditionals
Operator Name Example
=== Strict equality 5 === 2 + 4
!== Strict-non-equality 5 !== 2 + 3
< Less than 10 < 6
> Greater than 10 > 20
<= Less than or equal to 3 <= 2
>= Greater than or equal to 5 >= 4
Conditionals
var iceCream = 'chocolate';
if (iceCream === 'chocolate')
{
alert('Yay, I love chocolate ice cream!');
}
else
{
alert('Awwww, but chocolate is my favorite...');
}
Loops
• For
• While
• Do.. While
for (i = 0; i < 10; i++) {
text += "The number is " + I;
}
while (i < 10) {
text += "The number is " + i;
i++;
}
do {
text += "The number is " + i;
i++;
}
while (i < 10);
Functions
• Code reusal
• No parameter type
• No return type
• Can pass any type in invocation
function multiply(num1,num2) {
var result = num1 * num2;
return result;
}
var x = multiply(4,7);
x = multiply(20,20);
x = multiply(0.5,3);
Functions
• Special functions
• alert(“Hi”);
• confirm(“Are you gonna eat that?”);
• prompt(“Enter your age [male only]:”);
• getElementById(“elementId”);
• String functions
• split()
• Array functions
• find()
Events
• “things” that happen to HTML elements
• JavaScript react to these events
• User or browser actions
• Button clicked (onclick)
• Key pressed (onkeydown)
• Mouse over some element (onmouseover)
• Page loaded (onload)
• Event handlers are JavaScript functions
Events
<html>
<body>
<script type="text/javascript">
function changeText(){
document.getElementById('demo').innerHTML = 'Hello JavaScript!';
}
</script>
<h1>What Can JavaScript Do?</h1>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='changeText()'>Click Me!</button>
</body>
</html>
That’s all folks!
VISIT Https://www.W3schools.Com/js/default.Asp FOR FURTHER ENTERTAINMENT

More Related Content

What's hot

What's hot (20)

5 Steps to Mastering the Art of Seaside
5 Steps to Mastering the Art of Seaside5 Steps to Mastering the Art of Seaside
5 Steps to Mastering the Art of Seaside
 
JavaScript Good Practices
JavaScript Good PracticesJavaScript Good Practices
JavaScript Good Practices
 
Introduction of javascript
Introduction of javascriptIntroduction of javascript
Introduction of javascript
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
No audio --and welcome to this presentation
No audio --and welcome to this presentationNo audio --and welcome to this presentation
No audio --and welcome to this presentation
 
Martin Splitt "A short history of the web"
Martin Splitt "A short history of the web"Martin Splitt "A short history of the web"
Martin Splitt "A short history of the web"
 
Novajs
NovajsNovajs
Novajs
 
Marrying angular rails
Marrying angular railsMarrying angular rails
Marrying angular rails
 
AngularJS
AngularJSAngularJS
AngularJS
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
 
Namespace less engine
Namespace less engineNamespace less engine
Namespace less engine
 
Web Vector Graphics
Web Vector GraphicsWeb Vector Graphics
Web Vector Graphics
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
High Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScriptHigh Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScript
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_query
 
Getting Started with Web
Getting Started with WebGetting Started with Web
Getting Started with Web
 
Stateful Application Server_JRubyConf13_Lukas Rieder
Stateful Application Server_JRubyConf13_Lukas RiederStateful Application Server_JRubyConf13_Lukas Rieder
Stateful Application Server_JRubyConf13_Lukas Rieder
 
Revenge of the ORMs
Revenge of the ORMsRevenge of the ORMs
Revenge of the ORMs
 
Drupal front-end performance
Drupal front-end performance Drupal front-end performance
Drupal front-end performance
 
AngularJS and SPA
AngularJS and SPAAngularJS and SPA
AngularJS and SPA
 

Similar to Javascript: A sneak preview

Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!
Gill Cleeren
 

Similar to Javascript: A sneak preview (20)

Run Node Run
Run Node RunRun Node Run
Run Node Run
 
Java script
Java scriptJava script
Java script
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!Top 10 HTML5 features every developer should know!
Top 10 HTML5 features every developer should know!
 
JavaScript Basics with baby steps
JavaScript Basics with baby stepsJavaScript Basics with baby steps
JavaScript Basics with baby steps
 
Week 7 html css js
Week 7   html css jsWeek 7   html css js
Week 7 html css js
 
MSTCCU'16 - Aspiration Webbers - Session 4 - intro. to JS
MSTCCU'16 - Aspiration Webbers - Session 4 - intro. to JSMSTCCU'16 - Aspiration Webbers - Session 4 - intro. to JS
MSTCCU'16 - Aspiration Webbers - Session 4 - intro. to JS
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
Harness SharePoint and jQuery to Make Dynamic Displays and Applications
 Harness SharePoint and jQuery to Make Dynamic Displays and Applications Harness SharePoint and jQuery to Make Dynamic Displays and Applications
Harness SharePoint and jQuery to Make Dynamic Displays and Applications
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
 
Web Design Workshop Part 2
Web Design Workshop Part 2Web Design Workshop Part 2
Web Design Workshop Part 2
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
 
Unit - 4 all script are here Javascript.pptx
Unit - 4 all script are here Javascript.pptxUnit - 4 all script are here Javascript.pptx
Unit - 4 all script are here Javascript.pptx
 
Java script
Java scriptJava script
Java script
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Javascript: A sneak preview

  • 1. JavaScript A SNEAK PREVIEW PRESENTATION </script>
  • 2. Why we need JavaScript • HTML to define the content of web pages • CSS to specify the layout of web pages • JavaScript to program the behavior of web pages
  • 3. JavaScript is nice because • Adds interactivity (event handling) • Manipulates page contents dynamically • Does real time validations • No reloads – All is executed on browser • Makes asynchronous server calls • Performs calculations on the spot • Controls Browser, Window, Keyboard, Mouse, Cookies.. • Can accept third party libraries
  • 4. Where to place JavaScript <html> <body> … <script language="javascript" type="text/javascript"> … </script> </body> </html> <script type="text/javascript" src="filename.js" ></script>
  • 5. Variables • No declaration of types • Name cannot start with numbers • JavaScript is case sensitive • myVariable is a different variable to myvariable The semicolon at the end of the line is not mandatory var myVariable; myVariable = 'Bob'; var myVariable = 'Bob'; myVariable = 'Steve';
  • 6. Data Types Variable Example String var myVariable = 'Bob'; Number var myVariable = 10; Boolean var myVariable = true; Array var myVariable = [1,'Bob','Steve',10]; Refer to each member of the array like this: myVariable[0], myVariable[1], etc. Object var myVariable = document.querySelector('h1'); All of the above examples too.
  • 7. Comments /* Everything in between is a comment */ // This is also a comment
  • 8. Operators Operator Symbol(s) Example add/concatenation + 6 + 9; "Hello " + "world!"; subtract, multiply, divide -, *, / 9 - 3; 8 * 2; 9 / 3; assignment operator = var myVariable = 'Bob'; Identity operator === var myVariable = 3; myVariable === 4; negation, not equal !, !== var myVariable = 3; myVariable !== 3;
  • 9. Conditionals Operator Name Example === Strict equality 5 === 2 + 4 !== Strict-non-equality 5 !== 2 + 3 < Less than 10 < 6 > Greater than 10 > 20 <= Less than or equal to 3 <= 2 >= Greater than or equal to 5 >= 4
  • 10. Conditionals var iceCream = 'chocolate'; if (iceCream === 'chocolate') { alert('Yay, I love chocolate ice cream!'); } else { alert('Awwww, but chocolate is my favorite...'); }
  • 11. Loops • For • While • Do.. While for (i = 0; i < 10; i++) { text += "The number is " + I; } while (i < 10) { text += "The number is " + i; i++; } do { text += "The number is " + i; i++; } while (i < 10);
  • 12. Functions • Code reusal • No parameter type • No return type • Can pass any type in invocation function multiply(num1,num2) { var result = num1 * num2; return result; } var x = multiply(4,7); x = multiply(20,20); x = multiply(0.5,3);
  • 13. Functions • Special functions • alert(“Hi”); • confirm(“Are you gonna eat that?”); • prompt(“Enter your age [male only]:”); • getElementById(“elementId”); • String functions • split() • Array functions • find()
  • 14. Events • “things” that happen to HTML elements • JavaScript react to these events • User or browser actions • Button clicked (onclick) • Key pressed (onkeydown) • Mouse over some element (onmouseover) • Page loaded (onload) • Event handlers are JavaScript functions
  • 15. Events <html> <body> <script type="text/javascript"> function changeText(){ document.getElementById('demo').innerHTML = 'Hello JavaScript!'; } </script> <h1>What Can JavaScript Do?</h1> <p id="demo">JavaScript can change HTML content.</p> <button type="button" onclick='changeText()'>Click Me!</button> </body> </html>
  • 16. That’s all folks! VISIT Https://www.W3schools.Com/js/default.Asp FOR FURTHER ENTERTAINMENT