SlideShare a Scribd company logo
Introduction to JavaScript
Hands-on
Getting Started with JavaScript
Kevin Hoyt and Mihai Corlan | Adobe
About Us
Kevin Hoyt
@krhoyt
Adobe Evangelist
Mihai Corlan
@mcorlan
Adobe Evangelist
What is JavaScript
1. Prototype-based
2. Scripting language
3. Dynamic
4. Weakly typed
5. First-class functions
6. Multi-paradigm
@krhoyt @mcorlan
Adding JavaScript to a Page - Inline
<script type="text/javascript">
document.writeln( "It works!" );
</script>
@krhoyt @mcorlan
Adding JavaScript to a Page - External
<script
src="myscript.js"
type="text/javascript">
</script>
document.writeln( "It works!" );
In your HTML file:
In the "myscript.js" file:
@krhoyt @mcorlan
Variables
var _myName = "Mihai";
var hisName = "Kevin";
Variables are defined using the special keyword "var"
followed by a valid name. Valid names can be any
combination of letters, "$" and "_".
@krhoyt @mcorlan
Variable Types
var myVar; // undefined
var myVar = null; // null
var myVar = 3.14; // Number
var myVar = "MAX"; // String
var myVar = true; // Boolean
var myVar = { // Object
first: "Mihai",
last: "Corlan"
};
@krhoyt @mcorlan
Arrays
var simpleArray = [1, 2, 3, 4];
var complexArray = new Array();
complexArray.push( 1 );
complexArray.push( "Kevin" );
An array is an ordered list of variables. Values inside
the array can be of any type. You can even mix the
types for each value.
@krhoyt @mcorlan
Custom Data Types
An object is a collection of properties assigned to a
single variable.
var myVar = {
index: 0,
name: "Mihai Corlan",
isAdobe: true
};
@krhoyt @mcorlan
Control Structures - if ... else
var color = "red";
if( color === "red" ) // === vs. ==
{
document.body.style.backgroundColor = "red";
} else if( color === "blue" ) {
document.body.style.backgroundColor = "blue";
} else {
document.body.style.backgroundColor = "#CCFFFF";
}
@krhoyt @mcorlan
Control Structures - switch ... case
var color = "red";
switch( color ) {
case "red":
document.writeln( "It is red." );
break;
case "blue":
document.writeln( "It is blue." );
break;
default:
document.writeln( "Huh?" );
break;
}
@krhoyt @mcorlan
Control Structures - for
var div;
var numbers = [1, 2, 3, 4, 5, 6];
for( var n = 0; n < numbers.length; n++ )
{
div = document.createElement( "div" );
div.innerHTML = numbers[n];
div.style.fontSize = numbers[n] + "em";
document.body.appendChild( div );
}
@krhoyt @mcorlan
Control Structures - while
var current = 0;
var limit = 5;
while( current < limit )
{
document.writeln( current );
current = current + 1;
}
@krhoyt @mcorlan
Control Structures - do ... while
var current = 0;
var limit = 5;
do {
document.writeln( current );
current = current + 1;
} while( current < limit );
@krhoyt @mcorlan
Functions
function sayHello()
{
document.writeln( "Hello World!" );
}
sayHello();
A function is a block of code that will be executed
when it is called. Functions allow you to reuse code
that needs to be executed more than once, or in more
than one place.
@krhoyt @mcorlan
Functions - Arguments and Return Values
function addNumbers( value1, value2 )
{
return value1 + value2;
}
var sum = addNumbers( 2, 2 );
document.writeln( sum );
@krhoyt @mcorlan
Variable Scope
var value = 0;
function tellMe() {
var value = 1;
document.writeln( value );
}
tellMe(); // Will be 1
document.writeln( value ); // Will be 0
JavaScript has one "global" scope. Each function
also has its own scope. If you omit "var" then values
default to the global scope.
@krhoyt @mcorlan
Handling Events
document.images[0].addEventListener(
"click",
function() { alert( "I was clicked!" ); }
);
document.addEventListener(
"mousemove",
doMouseMove
);
Events are signals generated when specific actions
occur. JavaScript is aware of these signals and can
run scripts in reaction to them.
@krhoyt @mcorlan
Handling Events
@krhoyt @mcorlan
focus When a form element is selected
blur When a form element is deselected
change User updates a form element value
click Mouse is clicked on an element
mousedown The mouse is pressed
mousemove Mouse is moved while pressed
mouseup The mouse is released
touchstart A touch is started
touchmove A registred touch point has moved
touchend A touch has ended
And many more!
Selectors
Type: IMG, DIV, INPUT
Attribute: INPUT[type="text"]
Class: .green, INPUT.green
ID: #username, #password
Psuedo: DIV > p:first-child
@krhoyt @mcorlan
Selectors
var cat = null;
var cats = null;
cat = document.querySelector( '#cat' );
cats = document.querySelectorAll( '.cat' );
for( var c = 0; c < cats.length; c++ )
{
...
}
@krhoyt @mcorlan
Debugging
@krhoyt @mcorlan
+
Debugging
for( var m = 0; m < 10; m++ )
{
// Log value to developer tooling
console.log( 'Number is: ' + m );
}
// Stops execution
// Shows some value
alert( 'Done at: ' + m );
@krhoyt @mcorlan
What is JavaScript
1. Prototype-based
2. Scripting language
3. Dynamic
4. Weakly typed
5. First-class functions
6. Multi-paradigm
@krhoyt @mcorlan
Introduction to JavaScript
Hands-on
Getting Started with JavaScript
Kevin Hoyt and Mihai Corlan | Adobe

More Related Content

What's hot (20)

PPT
React.js 20150828
LearningTech
 
PPTX
Dwr explanation
Arun Maharana
 
DOCX
Asp.docx(.net --3 year) programming
Ankit Gupta
 
DOCX
Cara membuka workbook yang terproteksi
Irmaoly
 
PPTX
Node js crash course session 6
Abdul Rahman Masri Attal
 
PDF
Java script how to
julian vega
 
PDF
Mvvmintroduction 130725124207-phpapp01
Nguyen Cuong
 
PPT
JavaScript Training
Ramindu Deshapriya
 
PDF
Update statement in PHP
Vineet Kumar Saini
 
PDF
Dominando o Data Binding no Android
Nelson Glauber Leal
 
PDF
Dominando o Data Binding no Android
Nelson Glauber Leal
 
PDF
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
PPTX
2.java script dom
PhD Research Scholar
 
PDF
Web 6 | JavaScript DOM
Mohammad Imam Hossain
 
PPTX
Java script objects
AbhishekMondal42
 
PPT
Session vii(java scriptbasics)
Shrijan Tiwari
 
PDF
Knockout vs. angular
MaslowB
 
PDF
Demystifying cache in doctrine ORM
Luís Cobucci
 
DOCX
Web Scripting Project JavaScripts and HTML WebPage
Sunny U Okoro
 
PPTX
Knockoutjs
Karthik Sathyanarayanan
 
React.js 20150828
LearningTech
 
Dwr explanation
Arun Maharana
 
Asp.docx(.net --3 year) programming
Ankit Gupta
 
Cara membuka workbook yang terproteksi
Irmaoly
 
Node js crash course session 6
Abdul Rahman Masri Attal
 
Java script how to
julian vega
 
Mvvmintroduction 130725124207-phpapp01
Nguyen Cuong
 
JavaScript Training
Ramindu Deshapriya
 
Update statement in PHP
Vineet Kumar Saini
 
Dominando o Data Binding no Android
Nelson Glauber Leal
 
Dominando o Data Binding no Android
Nelson Glauber Leal
 
Web 5 | JavaScript Events
Mohammad Imam Hossain
 
2.java script dom
PhD Research Scholar
 
Web 6 | JavaScript DOM
Mohammad Imam Hossain
 
Java script objects
AbhishekMondal42
 
Session vii(java scriptbasics)
Shrijan Tiwari
 
Knockout vs. angular
MaslowB
 
Demystifying cache in doctrine ORM
Luís Cobucci
 
Web Scripting Project JavaScripts and HTML WebPage
Sunny U Okoro
 

Viewers also liked (6)

PPT
Flash and Hardware
Kevin Hoyt
 
PPT
Ignite A Cigar
Kevin Hoyt
 
KEY
Exploring Canvas
Kevin Hoyt
 
PPT
Ignite a Cigar (Technical)
Kevin Hoyt
 
PDF
Exploring Canvas
Kevin Hoyt
 
PDF
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Flash and Hardware
Kevin Hoyt
 
Ignite A Cigar
Kevin Hoyt
 
Exploring Canvas
Kevin Hoyt
 
Ignite a Cigar (Technical)
Kevin Hoyt
 
Exploring Canvas
Kevin Hoyt
 
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Ad

Similar to Getting Started with JavaScript (20)

PPT
JavaScript - An Introduction
Manvendra Singh
 
PPTX
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
PPTX
JavaScript_III.pptx
rashmiisrani1
 
PDF
lect4
tutorialsruby
 
PDF
lect4
tutorialsruby
 
PDF
Client sidescripting javascript
Selvin Josy Bai Somu
 
PDF
Lecture 10.pdf
ssuser0890d1
 
PPTX
Pawangvvhgvhg hbhvhhhhvhjjkvhvghvhgh.pptx
ramtiwari7081
 
PPTX
Pawanasfdcvgfgfxgndrfdrxjdrfmjfgtdtdt.pptx
ramtiwari7081
 
PPTX
Basics of Java Script (JS)
Ajay Khatri
 
PPTX
Java Script
Kalidass Balasubramaniam
 
PDF
Intro to JavaScript
Dan Phiffer
 
PPT
Java Script
Sarvan15
 
PDF
Java Script
Sarvan15
 
PPTX
Java Script basics and DOM
Sukrit Gupta
 
PPT
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
PDF
JavaScript Getting Started
Hazem Hagrass
 
PPT
JavaScript ppt for introduction of javascripta
nehatanveer5765
 
PPTX
Lecture 5 javascript
Mujtaba Haider
 
PDF
Lecture 03 - JQuery.pdf
Lê Thưởng
 
JavaScript - An Introduction
Manvendra Singh
 
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
JavaScript_III.pptx
rashmiisrani1
 
Client sidescripting javascript
Selvin Josy Bai Somu
 
Lecture 10.pdf
ssuser0890d1
 
Pawangvvhgvhg hbhvhhhhvhjjkvhvghvhgh.pptx
ramtiwari7081
 
Pawanasfdcvgfgfxgndrfdrxjdrfmjfgtdtdt.pptx
ramtiwari7081
 
Basics of Java Script (JS)
Ajay Khatri
 
Intro to JavaScript
Dan Phiffer
 
Java Script
Sarvan15
 
Java Script
Sarvan15
 
Java Script basics and DOM
Sukrit Gupta
 
Presentation JavaScript Introduction Data Types Variables Control Structure
SripathiRavi1
 
JavaScript Getting Started
Hazem Hagrass
 
JavaScript ppt for introduction of javascripta
nehatanveer5765
 
Lecture 5 javascript
Mujtaba Haider
 
Lecture 03 - JQuery.pdf
Lê Thưởng
 
Ad

Recently uploaded (20)

PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
July Patch Tuesday
Ivanti
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 

Getting Started with JavaScript

  • 1. Introduction to JavaScript Hands-on Getting Started with JavaScript Kevin Hoyt and Mihai Corlan | Adobe
  • 2. About Us Kevin Hoyt @krhoyt Adobe Evangelist Mihai Corlan @mcorlan Adobe Evangelist
  • 3. What is JavaScript 1. Prototype-based 2. Scripting language 3. Dynamic 4. Weakly typed 5. First-class functions 6. Multi-paradigm @krhoyt @mcorlan
  • 4. Adding JavaScript to a Page - Inline <script type="text/javascript"> document.writeln( "It works!" ); </script> @krhoyt @mcorlan
  • 5. Adding JavaScript to a Page - External <script src="myscript.js" type="text/javascript"> </script> document.writeln( "It works!" ); In your HTML file: In the "myscript.js" file: @krhoyt @mcorlan
  • 6. Variables var _myName = "Mihai"; var hisName = "Kevin"; Variables are defined using the special keyword "var" followed by a valid name. Valid names can be any combination of letters, "$" and "_". @krhoyt @mcorlan
  • 7. Variable Types var myVar; // undefined var myVar = null; // null var myVar = 3.14; // Number var myVar = "MAX"; // String var myVar = true; // Boolean var myVar = { // Object first: "Mihai", last: "Corlan" }; @krhoyt @mcorlan
  • 8. Arrays var simpleArray = [1, 2, 3, 4]; var complexArray = new Array(); complexArray.push( 1 ); complexArray.push( "Kevin" ); An array is an ordered list of variables. Values inside the array can be of any type. You can even mix the types for each value. @krhoyt @mcorlan
  • 9. Custom Data Types An object is a collection of properties assigned to a single variable. var myVar = { index: 0, name: "Mihai Corlan", isAdobe: true }; @krhoyt @mcorlan
  • 10. Control Structures - if ... else var color = "red"; if( color === "red" ) // === vs. == { document.body.style.backgroundColor = "red"; } else if( color === "blue" ) { document.body.style.backgroundColor = "blue"; } else { document.body.style.backgroundColor = "#CCFFFF"; } @krhoyt @mcorlan
  • 11. Control Structures - switch ... case var color = "red"; switch( color ) { case "red": document.writeln( "It is red." ); break; case "blue": document.writeln( "It is blue." ); break; default: document.writeln( "Huh?" ); break; } @krhoyt @mcorlan
  • 12. Control Structures - for var div; var numbers = [1, 2, 3, 4, 5, 6]; for( var n = 0; n < numbers.length; n++ ) { div = document.createElement( "div" ); div.innerHTML = numbers[n]; div.style.fontSize = numbers[n] + "em"; document.body.appendChild( div ); } @krhoyt @mcorlan
  • 13. Control Structures - while var current = 0; var limit = 5; while( current < limit ) { document.writeln( current ); current = current + 1; } @krhoyt @mcorlan
  • 14. Control Structures - do ... while var current = 0; var limit = 5; do { document.writeln( current ); current = current + 1; } while( current < limit ); @krhoyt @mcorlan
  • 15. Functions function sayHello() { document.writeln( "Hello World!" ); } sayHello(); A function is a block of code that will be executed when it is called. Functions allow you to reuse code that needs to be executed more than once, or in more than one place. @krhoyt @mcorlan
  • 16. Functions - Arguments and Return Values function addNumbers( value1, value2 ) { return value1 + value2; } var sum = addNumbers( 2, 2 ); document.writeln( sum ); @krhoyt @mcorlan
  • 17. Variable Scope var value = 0; function tellMe() { var value = 1; document.writeln( value ); } tellMe(); // Will be 1 document.writeln( value ); // Will be 0 JavaScript has one "global" scope. Each function also has its own scope. If you omit "var" then values default to the global scope. @krhoyt @mcorlan
  • 18. Handling Events document.images[0].addEventListener( "click", function() { alert( "I was clicked!" ); } ); document.addEventListener( "mousemove", doMouseMove ); Events are signals generated when specific actions occur. JavaScript is aware of these signals and can run scripts in reaction to them. @krhoyt @mcorlan
  • 19. Handling Events @krhoyt @mcorlan focus When a form element is selected blur When a form element is deselected change User updates a form element value click Mouse is clicked on an element mousedown The mouse is pressed mousemove Mouse is moved while pressed mouseup The mouse is released touchstart A touch is started touchmove A registred touch point has moved touchend A touch has ended And many more!
  • 20. Selectors Type: IMG, DIV, INPUT Attribute: INPUT[type="text"] Class: .green, INPUT.green ID: #username, #password Psuedo: DIV > p:first-child @krhoyt @mcorlan
  • 21. Selectors var cat = null; var cats = null; cat = document.querySelector( '#cat' ); cats = document.querySelectorAll( '.cat' ); for( var c = 0; c < cats.length; c++ ) { ... } @krhoyt @mcorlan
  • 23. Debugging for( var m = 0; m < 10; m++ ) { // Log value to developer tooling console.log( 'Number is: ' + m ); } // Stops execution // Shows some value alert( 'Done at: ' + m ); @krhoyt @mcorlan
  • 24. What is JavaScript 1. Prototype-based 2. Scripting language 3. Dynamic 4. Weakly typed 5. First-class functions 6. Multi-paradigm @krhoyt @mcorlan
  • 25. Introduction to JavaScript Hands-on Getting Started with JavaScript Kevin Hoyt and Mihai Corlan | Adobe