SlideShare une entreprise Scribd logo
1  sur  14
D I N A G O L D S H T E I N
JavaScript Basics
Once Upon a Time
 Websites used to be static
 Space Jam
 HUJI
 Websites used frames
 Chiyuchon Net
 Lost-World
Behind the Scenes
 Single HTML file for each “page”
 Hard-code content into HTML
 Static navigation menus in separate frames
 Illusion of single URL using frames
And Nowadays…
 Highly interactive
 Single page applications
 Gmail
 Facebook
 Online games
 2048
 Cut the Rope
 All this thanks to JavaScript (and other stuff too )
Achieving Interactivity
 Interactivity and “navigational smoothness” are
achieved by running code on the client-side (inside
the browser)
 There used to be several client side languages, but
eventually JavaScript won the battle
 All modern browsers support JavaScript
 There are tons of third party libraries
HTML and JavaScript (and CSS)
HTML: The structure of
what’s on the screen
<ol id=“ranks”>
<li>Private</li>
<li>Corporal</li>
<li>Sergeant</li>
</ol>
CSS: Styling commands
for what’s on the screen
li { color: red }
ol { background: ... }
JS: Code that runs in the
background – the app’s
business logic
var list =
document.getElementById(
“ranks”);
var captain =
document.createElement(
“li”);
captain.innerHTML =
“Captain”;
list.appendChild(captain);
The
DOM
What Can JavaScript Do?
 Manipulate the DOM
 Create
 Remove
 Style
 Do mathematical calculations
 Store information in local storage and files
 Access the user’s location
 Draw shapes on the screen
 Fetch data from a web server
How Does it Work?
 Embed the <script></script> tag in your HTML:
 Inline
<script type=“text/javascript”>
// code goes here
</script>
 Or external (usually preferred)
<script type=“text/javascript” src=“script.js”/>
 If no configurations are present, browser executes
script as soon as it sees it before parsing the rest of
the HTML
Head or Body?
DEMO
Controlling Execution Time
 window.onload – will be executed when page has
completely loaded all content (including images,
script files, CSS files, etc.)
 document.ready – will be executed after the DOM is
ready (but might be before some content is loaded)
 Easy to use with jQuery: $(function () { ... })
 This is usually where you want to attach events, etc.
Fundamental JavaScript Concepts
var kitty = {
name: “Svetlana”,
age: 7,
purr: function () { console.log(“Purr...”); }
};
kitty.age = kitty.age + 1; // Happy birthday
kitty.purr();
var btn = document.getElementById(“myButton”);
btn.addEventListener(“click”, function () { ... });
Property
Method
Object
Event
Event
handler
Hello World (and More)
DEMO
Events and Scope
DEMO
Events and AJAX
DEMO

Contenu connexe

Tendances

Introduction to j query
Introduction to j queryIntroduction to j query
Introduction to j query
thewarlog
 
Single page applications mit asp.net mvc und der asp.net web api
Single page applications mit asp.net mvc und der asp.net web apiSingle page applications mit asp.net mvc und der asp.net web api
Single page applications mit asp.net mvc und der asp.net web api
Alexander Zeitler
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
philogb
 

Tendances (20)

JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
Vanjs backbone-powerpoint
Vanjs backbone-powerpointVanjs backbone-powerpoint
Vanjs backbone-powerpoint
 
Thinkin' Tags - Rapid Prototyping of CSS Layouts
Thinkin' Tags - Rapid Prototyping of CSS LayoutsThinkin' Tags - Rapid Prototyping of CSS Layouts
Thinkin' Tags - Rapid Prototyping of CSS Layouts
 
HTML5 : Web to the next level
HTML5 : Web to the next levelHTML5 : Web to the next level
HTML5 : Web to the next level
 
Introduction to j_query
Introduction to j_queryIntroduction to j_query
Introduction to j_query
 
Notes on SF W3Conf
Notes on SF W3ConfNotes on SF W3Conf
Notes on SF W3Conf
 
Introduction to j query
Introduction to j queryIntroduction to j query
Introduction to j query
 
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStartBest Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
Modern frontend
Modern frontendModern frontend
Modern frontend
 
Single page applications mit asp.net mvc und der asp.net web api
Single page applications mit asp.net mvc und der asp.net web apiSingle page applications mit asp.net mvc und der asp.net web api
Single page applications mit asp.net mvc und der asp.net web api
 
Building web front ends using single page applications
Building web front ends using single page applicationsBuilding web front ends using single page applications
Building web front ends using single page applications
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Intro to bootcamp
Intro to bootcampIntro to bootcamp
Intro to bootcamp
 
Os mobile
Os mobileOs mobile
Os mobile
 
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
Angularjs vs Dojo toolkit | SuperSpeaker@CodeCamp Iasi 2014
 
FEI 2013 - Nette framework
FEI 2013 - Nette frameworkFEI 2013 - Nette framework
FEI 2013 - Nette framework
 
Introduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScriptIntroduction to the wonderful world of JavaScript
Introduction to the wonderful world of JavaScript
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 

Similaire à JavaScript Basics

01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
Tommy Vercety
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
Justin Cataldo
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
Mark Rackley
 

Similaire à JavaScript Basics (20)

01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
 
Html5 & less css
Html5 & less cssHtml5 & less css
Html5 & less css
 
Html5
Html5Html5
Html5
 
Js Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform betterJs Saturday 2013 your jQuery could perform better
Js Saturday 2013 your jQuery could perform better
 
Html5
Html5Html5
Html5
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 r...
Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 r...Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 r...
Windows 8 Pure Imagination - 2012-11-24 - Getting your HTML5 game Windows 8 r...
 
Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~Attractive HTML5~開発者の視点から~
Attractive HTML5~開発者の視点から~
 
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript AppsBusy Developer's Guide to Windows 8 HTML/JavaScript Apps
Busy Developer's Guide to Windows 8 HTML/JavaScript Apps
 
Practical tipsmakemobilefaster oscon2016
Practical tipsmakemobilefaster oscon2016Practical tipsmakemobilefaster oscon2016
Practical tipsmakemobilefaster oscon2016
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Edge of the Web
Edge of the WebEdge of the Web
Edge of the Web
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Echo HTML5
Echo HTML5Echo HTML5
Echo HTML5
 
Html 5 - What's new?
Html 5 - What's new?Html 5 - What's new?
Html 5 - What's new?
 
Decoding the Web
Decoding the WebDecoding the Web
Decoding the Web
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
The Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devicesThe Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devices
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 

Plus de Dina Goldshtein

Plus de Dina Goldshtein (17)

How Does the Internet Work? (Wix she codes; branch)
How Does the Internet Work? (Wix she codes; branch)How Does the Internet Work? (Wix she codes; branch)
How Does the Internet Work? (Wix she codes; branch)
 
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
Self-Aware Applications: Automatic Production Monitoring (SDP November 2017)
 
Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)Look Mommy, No GC! (TechDays NL 2017)
Look Mommy, No GC! (TechDays NL 2017)
 
Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)
Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)
Self-Aware Applications: Automatic Production Monitoring (TechDays NL 2017)
 
ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)
ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)
ETW - Monitor Anything, Anytime, Anywhere (Velocity NYC 2017)
 
Look Mommy, no GC! (.NET Summit 2017)
Look Mommy, no GC! (.NET Summit 2017)Look Mommy, no GC! (.NET Summit 2017)
Look Mommy, no GC! (.NET Summit 2017)
 
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
Self-Aware Applications: Automatic Production Monitoring (NDC Sydney 2017)
 
Look Mommy, no GC! (BrightSource)
Look Mommy, no GC! (BrightSource)Look Mommy, no GC! (BrightSource)
Look Mommy, no GC! (BrightSource)
 
ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)
ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)
ETW - Monitor Anything, Anytime, Anywhere (NDC Oslo 2017)
 
Look Mommy, no GC! (SDP May 2017)
Look Mommy, no GC! (SDP May 2017)Look Mommy, no GC! (SDP May 2017)
Look Mommy, no GC! (SDP May 2017)
 
Look Mommy, No GC! (Codecamp Iasi 2017)
Look Mommy, No GC! (Codecamp Iasi 2017)Look Mommy, No GC! (Codecamp Iasi 2017)
Look Mommy, No GC! (Codecamp Iasi 2017)
 
Look Mommy, No GC! (NDC London 2017)
Look Mommy, No GC! (NDC London 2017)Look Mommy, No GC! (NDC London 2017)
Look Mommy, No GC! (NDC London 2017)
 
How does the Internet Work?
How does the Internet Work?How does the Internet Work?
How does the Internet Work?
 
How does the Internet Work?
How does the Internet Work?How does the Internet Work?
How does the Internet Work?
 
Things They Don’t Teach You @ School
Things They Don’t Teach You @ SchoolThings They Don’t Teach You @ School
Things They Don’t Teach You @ School
 
What's New in C++ 11/14?
What's New in C++ 11/14?What's New in C++ 11/14?
What's New in C++ 11/14?
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 

Dernier

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
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
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
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Dernier (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
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
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
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
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%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
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
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
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.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
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

JavaScript Basics

  • 1. D I N A G O L D S H T E I N JavaScript Basics
  • 2. Once Upon a Time  Websites used to be static  Space Jam  HUJI  Websites used frames  Chiyuchon Net  Lost-World
  • 3. Behind the Scenes  Single HTML file for each “page”  Hard-code content into HTML  Static navigation menus in separate frames  Illusion of single URL using frames
  • 4. And Nowadays…  Highly interactive  Single page applications  Gmail  Facebook  Online games  2048  Cut the Rope  All this thanks to JavaScript (and other stuff too )
  • 5. Achieving Interactivity  Interactivity and “navigational smoothness” are achieved by running code on the client-side (inside the browser)  There used to be several client side languages, but eventually JavaScript won the battle  All modern browsers support JavaScript  There are tons of third party libraries
  • 6. HTML and JavaScript (and CSS) HTML: The structure of what’s on the screen <ol id=“ranks”> <li>Private</li> <li>Corporal</li> <li>Sergeant</li> </ol> CSS: Styling commands for what’s on the screen li { color: red } ol { background: ... } JS: Code that runs in the background – the app’s business logic var list = document.getElementById( “ranks”); var captain = document.createElement( “li”); captain.innerHTML = “Captain”; list.appendChild(captain); The DOM
  • 7. What Can JavaScript Do?  Manipulate the DOM  Create  Remove  Style  Do mathematical calculations  Store information in local storage and files  Access the user’s location  Draw shapes on the screen  Fetch data from a web server
  • 8. How Does it Work?  Embed the <script></script> tag in your HTML:  Inline <script type=“text/javascript”> // code goes here </script>  Or external (usually preferred) <script type=“text/javascript” src=“script.js”/>  If no configurations are present, browser executes script as soon as it sees it before parsing the rest of the HTML
  • 10. Controlling Execution Time  window.onload – will be executed when page has completely loaded all content (including images, script files, CSS files, etc.)  document.ready – will be executed after the DOM is ready (but might be before some content is loaded)  Easy to use with jQuery: $(function () { ... })  This is usually where you want to attach events, etc.
  • 11. Fundamental JavaScript Concepts var kitty = { name: “Svetlana”, age: 7, purr: function () { console.log(“Purr...”); } }; kitty.age = kitty.age + 1; // Happy birthday kitty.purr(); var btn = document.getElementById(“myButton”); btn.addEventListener(“click”, function () { ... }); Property Method Object Event Event handler
  • 12. Hello World (and More) DEMO

Notes de l'éditeur

  1. כל האינטראקטיביות הזאת מושגת תודות לג׳אווה סקריפט, וכמובן תמיכה מהדפדפנים ואנשים שכתבו ספריות וכו׳ וכו׳. אבל בבסיס של כל זה עומדת היכולת לכתוב קוד שרץ בצד המשתמש וזה נעשה בימינו באמצעות ג׳אווה סקריפט. אני לא אכנס לפרטי ההיסטוריה, אני גם לא כל כך מתמצאת אבל רק אציין כעת שפעם היו עוד שפות שניתן היה לכתוב איתן קוד שירוץ בדפדפן אבל בסופו של דבר ג׳אווה סקריפט נצחה והיא השפה השלטת היום. למעשה, אם תחפשו באינטרנט את שפת התכנות הפופולרית ביותר תגלו ש(נכון ל-2013) היא השפה הרביעית בפופולריות (http://langpop.com/). יש להם שיטה שבה הם מודדים פופולריות אבל זה לא כל כך קשור לנושא. הפואנטה היא שזו שפה מאוד פופולרית ויש בוכטה קוד שכתובה בה. כל הדפדפנים המודרניים תומכים בג׳אווה סקריפט, יש המון ספריות חיצוניות, המון חומרי קריאה גם באינטרנט וגם מודפסים, המון שאלות ב-stack overflow ובכלל המון תמיכה מקוונת.
  2. אנחנו ממש מתקרבים לת׳כלס. לפני שממש נתחיל לכתוב קוד צריך להסביר רק עוד שני דברים קצרים על האנטומיה של דף ווב. אפשר לומר שבגדול דף ווב מורכב משלושה חלקים עיקריים: 1. ה-HTML שמגדיר איך הדף נראה. הוא אומר איפה יש כותרות ומה כתוב בהן, איפה יש רשימות, איפה יש כפתורים ואיפה יש תמונות. ה-HTML כתוב בצורה היררכית שדומה מאוד ל-XML ובכך יוצרת גרף של כל האלמנטים שבעמוד. הגרף הזה נקרא (DOM (Document object model. כשדפדפן מקבל דף הוא יודע לפרסר את ה-DOM ולהבין ממנו איך צריך להציג את העמוד. 2. ה-CSS שקשור גם הוא באופן ישיר לתצוגה. הוא לא קובע מהם האלמנטים שנמצאים על הדף אבל הוא יכול לקבוע את כל הפרמטרים התצוגתיים שלהם. למשל, ניתן לקבוע שכל הכתפורים הם בצבע אדום ושכל האלמנטים של הרשימות יש להם רקע צהוב. ניתן לקבוע את המאפיינים האלה גם דרך ה-HTML אך נהוג לשמור ב-HTML רק את האלמנטים ואילו את ההגדרות של הצבעים וכו׳ לשמור ב-CSS. ככה זה מפריד את תחומי האחריות ומאפשר גם לחלוק את אותו העיצוב בין עמודים שונים. 3. הקוד שרץ הרקע בזמן שהעמוד מוצג. וזה מה שאנחנו נמתמקד בו בזמן שנותר.
  3. מה אנחנו יכולים לעשות בקוד? ובכל, הכל. אנחנו יכולים להתעסק עם ה-DOM – כלומר ליצור, להוריד, לשנות, לעצב אלמנטים, אפילו אם הם לא היו קיימים ב-HTML או ב-CSS המקוריים. אנחנו יכולים לעשות פעולות מתמטיות כמו חיבור, כפל, חילוק וכו׳. אנחנו יכולים לשמור מידע במיקום לוקאלי כדי שנוכל להמשיך לפעול ללא חיבור לאינטרנט. אנחנו יכולים לקבל מהמשתמש נתונים כמו טקסט, מספרים או קבצים ולעבד את הנתונים האלה או לשלוח אותם לשרת מרוחק. אנחנו יכולים לקבל את המיקום של המשתמש כדי שנוכל למשל לשנות את שפת האתר לפי המיקום או לעשות redirect לגרסה לוקאלית עם פרטים רלוונטיים למיקום. אנחנו יכולים לצייר צורות, תמונות, סרטים על המסך או להשמיע מוסיקה. אנחנו יכולים להביא מידע משרת אחר. ועוד ועוד.
  4. מה קורה מאחורי הקלעים? הדפדפנים תומכים באלמנט מיוחד מסוג script. האלמנט הזה יכול ממש להכיל בתוכו את הקוד או להפנות לקובץ חיצוני שמכיל את הקוד. זו כמובן האפשרות המועדפת משום שזה שומר לנו על סדר וניתן לתחזק את הקוד בנפרד מהתצוגה. גם יש סיכוי סביר שאנשים שונים עובדים על שני החלקים האלה. כאשר הדפדפן טוען את הדף, כמו שאמרנו קודם, הוא מפרסר את ה-DOM. אם אין קונפיגורציות מיוחדות (שלא נדבר עליהן כאן) אז ברגע שהוא נתקל באלמנט הסקריפט הוא לוקח את הקוד ומתחיל להרציץ אותן. עד שהוא לא מסיים להריץ הוא לא ממשיך לפרסר את שאר האלמנטים.
  5. לדף HTML יש שני חלקים – הראש והגוף. הראש מופיע לפני הגוף ואפשר לשים בו כל מיני דברים או למשל הפניה לסקריפטים או ל-CSS-ים ואילו בגוף כותבים ממש את תוכן העמוד. את הסקריפטים נהוג לשים באחד מהקצוות של הדף – או בראש או בתחתית הגוף. האם זה משנה? כאן אנחנו נתקלים לראשונה ב-JSFIDDLE. זה אתר שמאפשר בקלות לכתוב דף ווב עם תצוגה וקוד והכל ולהריץ אותו. יש לו שלושה חלונות לעריכה של האתר וחלון אחד של תצוגה. יש לו גם אופציה להוסיף ספריות סטנדרטיות אבל אנחנו לא נשתמש בזה עכשיו ונכתוב קוד ג׳אווה סקריפט טהור. חוץ מזה, מה שנחמד באתר הוא שהוא פוטר אותנו מהתעסקות עם כל מיני דברים טכניים שצריך לכתוב כדי לבנות אתר. ב-HTML רגיל יש כל מיני מעטפות שצריך לכתוב אבל האתר הזה עושה את זה בשבילנו. למה הקוד עובד כשהוא מופיע בגוף ולא בראש? ובכן, כפי שאמרנו, הקוד רץ מיד כשהדפדפן פוגש את האלמנט. אם הדפדפן פוגש את האלמנט לפני ששאר האלמנטים מוגדרים אז הקוד פשוט לא מצליח לעשות כלום...