SlideShare a Scribd company logo
1 of 15
JavaScript Training
Goal Trainers Format
• Lecture
• Exercises
• Ask Questions!
• bitovi/js-training
Basic JS
JavaScript and the DOM
var, primitives, and objects
functions and closures
this, and prototypes
document.getElementById('dog’)
A dynamic, weakly typed, prototype-
based language with first-class
functions.
A language-neutral interface that allows
programs to dynamically access and update
the content, structure and style of documents.
A document format based on SGML used to
describe the elements of a hypertext
document.
What Happens?
GET http://helloworld.com/index.html
<html>
<head>
<script type='text/javascript'>
alert('hello world');
</script>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Server
DOM
<html>
<head>
<script type='text/javascript'>
"<html>n<head><script … "
JS
Tokenize: alert, (, "hello world", ), ;
Parse:
[{ "value": "(", "arity": "binary",
"first": {"value": "alert"},
"second": [{ "value": "hello world"}]
}]
Run:
- lookup alert
- call with "hello world"
DOM
</script></head>
<body><h1>Hello World</h1></body>
</html>
GET http://helloworld.com/index.html
documentElement
script
documentElement
head
script
head
body
h1
Hello World
JavaScript is ...
a dynamic, weakly typed, prototype-based
language with first-class functions.
JavaScript != Java
JavaScript == A real programming language
JavaScript == ECMAScript == JScript
JavaScript != Document Object Model
JS is Dynamic
Compilation and execution happen together.
var propMap = {
val: "value", html: "innerHTML"
};
for(var fnName in propMap){
$.prototype[fnName] = (function(prop){
return function(){
return this[prop];
}
})(propMap[fnName]);
}
Type associated with value, not variable.
var a = 1;
a = "one";
a = [1];
a = {one: 1};
JS is Weakly Typed
Treat like any object
var square = function(x){ return x*x },
mult = function(f1, f2){
return function(n){
return f1(n)*f2(n);
}
},
bigF = mult(square, square),
value = bigF(2); // 16
JS has 1st Class Functions
CREATE
RETURN
ARG
Prototype looks up inherited and shared properties.
has_hair
JS is Prototype Based
Mammal Chordate Animal
Chordate
Object
Animal
Object
Animal
p
prototype
proto proto
has_spine toString
prototype prototype
Summary
JS Representation of HTML and browser.
Dynamic, weakly typed, prototype-
based language with first-class
functions and some data types.
next week: Types Operators And Primitives
Questions?
https://gitter.im/bitovi/js-training
What’s your experience level?
What do you want to learn?

More Related Content

What's hot

What's hot (20)

Introduction to HTML, CSS, and Javascript
Introduction to HTML, CSS, and JavascriptIntroduction to HTML, CSS, and Javascript
Introduction to HTML, CSS, and Javascript
 
Introduction to web compoents
Introduction to web compoentsIntroduction to web compoents
Introduction to web compoents
 
JavaScript Introduction
JavaScript IntroductionJavaScript Introduction
JavaScript Introduction
 
CSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JSCSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JS
 
Indexed DB
Indexed DBIndexed DB
Indexed DB
 
Introduction to java_script
Introduction to java_scriptIntroduction to java_script
Introduction to java_script
 
Indexed db - the store in the browser
Indexed db - the store in the browserIndexed db - the store in the browser
Indexed db - the store in the browser
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
Plugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup AntwerpPlugin Development - WP Meetup Antwerp
Plugin Development - WP Meetup Antwerp
 
Client storage
Client storageClient storage
Client storage
 
Js slideshare
Js   slideshareJs   slideshare
Js slideshare
 
YMC Season 4 - Day6
YMC Season 4 - Day6YMC Season 4 - Day6
YMC Season 4 - Day6
 
Introduction of javascript
Introduction of javascriptIntroduction of javascript
Introduction of javascript
 
[WEB UI BASIC] JavaScript 1탄
[WEB UI BASIC] JavaScript 1탄[WEB UI BASIC] JavaScript 1탄
[WEB UI BASIC] JavaScript 1탄
 
Web Languages
Web LanguagesWeb Languages
Web Languages
 
[WEB UI BASIC] CSS_1
[WEB UI BASIC] CSS_1[WEB UI BASIC] CSS_1
[WEB UI BASIC] CSS_1
 
What's a web page made of?
What's a web page made of?What's a web page made of?
What's a web page made of?
 
Javascript
JavascriptJavascript
Javascript
 
ActiveDOM
ActiveDOMActiveDOM
ActiveDOM
 
Dom
DomDom
Dom
 

Viewers also liked

Types, Operators and Primitives
Types, Operators and PrimitivesTypes, Operators and Primitives
Types, Operators and Primitivesalexisabril
 
Element Styles and Positioning
Element Styles and PositioningElement Styles and Positioning
Element Styles and Positioningalexisabril
 
10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were PossibleLukas Eder
 

Viewers also liked (8)

Prototypes
PrototypesPrototypes
Prototypes
 
Context
ContextContext
Context
 
Types, Operators and Primitives
Types, Operators and PrimitivesTypes, Operators and Primitives
Types, Operators and Primitives
 
Events - Part 2
Events - Part 2Events - Part 2
Events - Part 2
 
Comparisons
ComparisonsComparisons
Comparisons
 
Closures
ClosuresClosures
Closures
 
Element Styles and Positioning
Element Styles and PositioningElement Styles and Positioning
Element Styles and Positioning
 
10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible10 SQL Tricks that You Didn't Think Were Possible
10 SQL Tricks that You Didn't Think Were Possible
 

Similar to Basic JS

Client-Side Web Development - An Overview
Client-Side Web Development - An OverviewClient-Side Web Development - An Overview
Client-Side Web Development - An OverviewCarlos J. Costa
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Modelchomas kandar
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCRGaurav Mishra
 
C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱NAVER D2
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONSyed Moosa Kaleem
 
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...Doris Chen
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScriptkoppenolski
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 

Similar to Basic JS (20)

Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
Client-Side Web Development - An Overview
Client-Side Web Development - An OverviewClient-Side Web Development - An Overview
Client-Side Web Development - An Overview
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCRDrupal7 Theming session on the occassion of  Drupal7 release party in Delhi NCR
Drupal7 Theming session on the occassion of Drupal7 release party in Delhi NCR
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱
 
前端概述
前端概述前端概述
前端概述
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
Java script
Java scriptJava script
Java script
 
Java Script
Java ScriptJava Script
Java Script
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
 
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
Develop High Performance Windows 8 Application with HTML5 and JavaScriptHigh ...
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
jQuery Intro
jQuery IntrojQuery Intro
jQuery Intro
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Basic JS

  • 1. JavaScript Training Goal Trainers Format • Lecture • Exercises • Ask Questions! • bitovi/js-training
  • 2.
  • 4. JavaScript and the DOM var, primitives, and objects functions and closures this, and prototypes
  • 6. A dynamic, weakly typed, prototype- based language with first-class functions. A language-neutral interface that allows programs to dynamically access and update the content, structure and style of documents. A document format based on SGML used to describe the elements of a hypertext document.
  • 7. What Happens? GET http://helloworld.com/index.html <html> <head> <script type='text/javascript'> alert('hello world'); </script> </head> <body> <h1>Hello World</h1> </body> </html>
  • 8. Server DOM <html> <head> <script type='text/javascript'> "<html>n<head><script … " JS Tokenize: alert, (, "hello world", ), ; Parse: [{ "value": "(", "arity": "binary", "first": {"value": "alert"}, "second": [{ "value": "hello world"}] }] Run: - lookup alert - call with "hello world" DOM </script></head> <body><h1>Hello World</h1></body> </html> GET http://helloworld.com/index.html documentElement script documentElement head script head body h1 Hello World
  • 9. JavaScript is ... a dynamic, weakly typed, prototype-based language with first-class functions. JavaScript != Java JavaScript == A real programming language JavaScript == ECMAScript == JScript JavaScript != Document Object Model
  • 10. JS is Dynamic Compilation and execution happen together. var propMap = { val: "value", html: "innerHTML" }; for(var fnName in propMap){ $.prototype[fnName] = (function(prop){ return function(){ return this[prop]; } })(propMap[fnName]); }
  • 11. Type associated with value, not variable. var a = 1; a = "one"; a = [1]; a = {one: 1}; JS is Weakly Typed
  • 12. Treat like any object var square = function(x){ return x*x }, mult = function(f1, f2){ return function(n){ return f1(n)*f2(n); } }, bigF = mult(square, square), value = bigF(2); // 16 JS has 1st Class Functions CREATE RETURN ARG
  • 13. Prototype looks up inherited and shared properties. has_hair JS is Prototype Based Mammal Chordate Animal Chordate Object Animal Object Animal p prototype proto proto has_spine toString prototype prototype
  • 14. Summary JS Representation of HTML and browser. Dynamic, weakly typed, prototype- based language with first-class functions and some data types. next week: Types Operators And Primitives

Editor's Notes

  1. In the last 7 years, I’ve either worked on directly or overseen 30 different JavaScript projects for about 7 companies: - big companies and small companies - teams of 2 and teams of 30 - for apps that target IE6 to mobile, phonegap and node webkit - I’ve even used other open source projects
  2. I think the key to JavaScript is really understanding what’s going on in memory. And the key to understanding what’s going on in memory is understanding what JS’s basic data types look like in memory and how JS’s operators are used to manipulate those data structures.
  3. feel / hood / sausage abstraction to diagram what’s going on, something you can use to teach new JS developers. Fortunately there’s just a few things to get right. Before we begin … this is a training! None of Us / All of us Level of skill
  4. a set of standards, a variety of SGML, used to tag the elements of ahypertext document
  5. Request is made Response is HTML DOM is built Immediately starts parsing response Finds Script Tag, stop parsing, hand over to JS JS tokenizes JS Runs statement by statement Calls alert Alert waits until ‘OK’ is clicked JS finishes Parsing continues H1 is parsed, and displayed Douglas crockford