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

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%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 & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
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...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

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