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

YMC Season 4 - Day6
YMC Season 4 - Day6YMC Season 4 - Day6
YMC Season 4 - Day6
theymc
 

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

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

Document Object Model
Document Object ModelDocument Object Model
Document Object Model
chomas kandar
 
C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱C3 웹기술로만드는모바일앱
C3 웹기술로만드는모바일앱
NAVER D2
 

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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

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