SlideShare a Scribd company logo
Introduction to web
programming with
JavaScript
#t11sessions
T11 Sessions
â—Ź A series of workshops, talks and presentations
from various practical fields
â—Ź Once per month
â—Ź Future workshops: Introduction to 3D graphics,
Introduction to philosophy etc.
â—Ź Inspired by T11, opened for all
â—Ź Facebook | t11sessions@gmail.com
Discourse and /me
â—Ź Been into this thing for ~10 years, but more actively
involved last ~5 years
â—Ź Happily unemployed
● Don’t expect magic - I’m here to give you some basic
knowledge and understanding (nothing is a black box)
â—Ź Continuation?
â—Ź Ask / Write questions
Discourse and /me
â—Ź Been into this thing for ~10 years, but more actively
involved last ~5 years
â—Ź Happily unemployed
● Don’t expect magic - I’m here to give you some basic
knowledge and understanding (nothing is a black box)
â—Ź Continuation?
â—Ź Ask / Write questions
â—Ź Task at the end
Backend / Frontend web development - what’s up with
that?
â—Ź Backend development is related mostly to the data, data
processing and calculations that are not directly
interacting with the user
â—Ź Frontend development is related to the elements of a
website that are visible to the user and that user interacts
with (combination of programming skills and aesthetics)
Backend web development - what’s up with that?
Frontend web development - what’s up with that?
Frontend web development - what’s up with that?
HTML (Hyper Text Markup Language) &
CSS (Cascading Style Sheets)
â—Ź HTML - web programming language that tells web
browsers how to structure and present content on a web
page (a, p, h1, h2, lists, header, footer, etc)
● CSS - defines a web page’s layout and in order to beautify
the page with design elements like colors, rounded
corners, gradients, and animation (attached to classes, ids
and so on)
HTML & CSS
<html>
<head>
<title>Motherfucking Website</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>This is a motherfucking website.</h1>
<p class="alert-text">This is a part of '.alert-text' class and it's painted red (color: #FF0000;)</p>
<p class="alert-text bold-text">This one extends '.alert-text' but it also adds an additional style</p>
</body>
</html>
HTML & CSS
<p class="alert-text">This is a part of '.alert-
text' class and it's obviously painted red
(color: #FF0000;)</p>
.alert-text {
color: #FF0000;
}
This is a part of '.alert-text' class and it's
painted red (color: #FF0000;)
Hey browser, show me that website!
â—Ź Simple scenario:
Open your preferable (Chrome, for example) browser, go
to a specific website -> http://motherfuckingwebsite.com/
Server
http://www.mothefuckingwebsite.com
Your
browser
BROWSER MAKES A GET REQUEST TO /
RESPONSE (HTML, JS, CSS, IMAGES)
USER REQUIRES A www.motherfuckingwebsite.com
46.164.50.177 66.147.244.191
index.html style.css
main.jsimage.jpg image_1.jpg
<script type="text/javascript" src="main.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<img src=”image.jpg”> <img src=”image_1.jpg”>
â—Ź JavaScript is not Java!
â—Ź Dynamic programming language most commonly used as
part of web websites (interacts with the user, controls the
browser, used for games, form validations etc) - basically
every website today is using JavaScript
● Simple, easy to read and understand and there’s a lot of
resources, which is both good and bad
â—Ź No need to setup anything in order to use it
JavaScript introduction
JavaScript - what exactly is it used for?
â—Ź Random calculations (1)
â—Ź Animations (1, 2, 3)
â—Ź Dynamically change colors and other styles (1, 2)
â—Ź Form validations
â—Ź Some more heavy shit! (1, 2)
â—Ź Dynamically load data
Javascript / Browser console
● Chrome / Firefox - right mouse click, then select “Inspect”
(or: CTRL + SHIFT + i)
● Examples: Declare a variable, string length, alert(“Hello
World!”), select elements, simple calculations, inspect and
change element etc.
â—Ź copy(someArray.toString());
JavaScript overview
â—Ź Variables (String, Number, Boolean, Array, Object)
â—Ź Operators (+, -, /, *, =, ===, !, !==, &&, ||)
â—Ź Events (associated mostly with user behavior)
● Conditionals (if, if else, switch, for, …)
â—Ź Functions (built-in functions + custom ones)
â—Ź Comments (/* comment */, // comment)
JavaScript variables
Types: String, Number, Boolean, Array, Object
â—Ź Comparable with mathematics (x = 10, y = 1, z = 5)
â—Ź var dayOfTheMonth; // declares a variable, undefined
â—Ź var dayOfTheMonth = 12; // declares and assigns a
variable, Number
â—Ź var monthName = "April"; // declares and assigns, String
â—Ź var dogs = ["Fluffy", "April", "Archibald"]; // Array
â—Ź var person = { firstName: "April", lastName: "June" }; //
Object
JavaScript operators
â—Ź Similar to math
â—Ź Basic operators: +, -, /, *
â—Ź Assignment operator: =
â—Ź Equality operators: ===, !==, <, >
â—Ź Logical operators: && (and), || (or) and ! (not)
JavaScript logical operators
â—Ź And (&&)
â—‹ true && true == true
â—‹ true && false == false
â—‹ false && true == false
â—‹ false && false == false
â—Ź Or (||)
â—‹ true || true == true
â—‹ true || false == true
â—‹ false || true == true
â—‹ false || false == false
â—Ź Not (!)
â—‹ !true == false
â—‹ !false == true
JavaScript logical operators
â—Ź And (&&)
â—‹ true && true == true
â—‹ true && false == false
â—‹ false && true == false
â—‹ false && false == false
â—Ź Or (||)
â—‹ true || true == true
â—‹ true || false == true
â—‹ false || true == true
â—‹ false || false == false
â—Ź Not (!)
â—‹ !true == false
â—‹ !false == true
JavaScript events
â—Ź Completely related to web development, and user
behavior
â—Ź You can define what to do when user clicks on a specific
button, selects an a different value in dropdown, gets
focus into a specific element and so on
â—Ź You can register them either in HTML or in JS
JavaScript statements (if)
var yourName = prompt("Please enter your name", ""); // gets the entered name
// if you don't provide a name, you'll become "Anonymous"
if (yourName === '') {
yourName = 'Anonymous';
}
JavaScript statements (if else)
var yourName = prompt("Please enter your name", ""); // gets the entered name
// if you don't provide a name, you'll become "Anonymous"
if (yourName === '') {
yourName = 'Anonymous';
} else if (yourName === 'Barack Obama') {
yourName = 'Anonymous';
}
JavaScript statements (switch)
var yourName = prompt("Please enter your name", ""); // gets the entered name
switch (yourName) {
case '':
yourName = 'Anonymous';
break;
case 'Barack Obama':
yourName = 'Anonymous';
break;
default: // all other cases
// don’t do anything
}
JavaScript statements (for)
var dogs = ["Fluffy", "April", "Archibald"]; // array of dogs
// prints out all the dogs
for (var i = 0; i < dogs.length; i++) {
alert(dogs[i]);
}
0 1 2
JavaScript statements (while)
var dogs = ["Fluffy", "April", "Archibald"]; // array of dogs
// does the same as for loop
var i = 0;
while (i < dogs.length) {
alert(dogs[i]);
i++;
}
0 1 2
JavaScript functions
â—Ź Closely connected with mathematics
â—Ź Built in functions (String has length, substring, text can be
converted into Number etc)
â—Ź Custom functions (write whatever you want)
JavaScript functions (examples)
Math
x2
(x - input)
x+y (x, y - inputs)
x + y / z (x, y, z - inputs)
JavaScript
function square(x) {
return x*x;
}
function addition(x, y) {
return x + y;
}
function randomFormula(x, y, z) {
return (x + y) / z;
}
JavaScript call
square(2); // 4
addition(4,4); // 8
randomFormula(5,5,2); // 5
JavaScript functions (examples)
Math
F = 9/5 * C + 32 (C - input)
C = 5/9 * (F - 32) (F - input)
D = b2
- 4*a*c
JavaScript
function celsiusToFahrenheit(celsius) {
return ((9 / 5) * celsius) + 32;
}
function fahrenheitToCelsius(fahrenheit) {
return (5 / 9) * (fahrenheit - 32);
}
function discriminant(a, b, c) {
return Math.pow(b,2) - (4 * a * c);
}
JavaScript call
celsiusToFahrenheit(30); // 86
fahrenheitToCelsius(77); // 25
discriminant(2,2,2); // -12
JavaScript vs. jQuery
â—Ź jQuery is basically just a wrapper for JavaScript, that
simplifies and beautifies the code
● document.getElementById(“test”) -> $(“#test”)
● document.getElementsByClassName(“test”) -> $(“.test”)
● Can be useful, but don’t rush :)
Tools
â—Ź For writing code: Sublime Text or Atom or Notepad++
â—Ź Write code online: JSFiddle
â—Ź Web browser by choice (recommendation: Chrome) and
browser console
â—Ź Versioning: Git and Github
â—Ź Simple Python server (for later use)
Where and how to continue?
â—Ź Codecademy (1, 2, 3, 4, overview)
â—Ź Coursera (1, 2, 3, 4, 5)
â—Ź Quick tutorials and exercises (1, 2, 3)
● 20 things I’ve learned about browsers and web
â—Ź Random JavaScript examples (1, 2, 3)
â—Ź Start your own project!
â—Ź Real life courses (1)
● Google, a lot! Beware: you’ll find a lot of bad examples online
Tasks - how to deal with it?
â—Ź Download .zip file
â—‹ index.html
â—‹ style.css
â—‹ main.js
â—‹ images/image.jpg
â—‹ images/image_1.jpg
Tasks - how to deal with it?
â—Ź Download .zip file
â—Ź Export files to /home/dev/t11sessions or similar directory
â—Ź Get Sublime Text or similar text/code editor
â—Ź Open index.html in Sublime Text and in preferable browser
(Open with…, then select preferable app)
â—Ź Observe index.html (both code and browser), try to
change/update things and go through TODO tasks
â—Ź Open main.js and style.css, read comments and TODO tasks
Thanks for your attention
peric.drazhen@gmail.com
@dperitch

More Related Content

PPTX
Lab #2: Introduction to Javascript
Walid Ashraf
 
PDF
JavaScript Programming
Sehwan Noh
 
PPT
Java Script ppt
Priya Goyal
 
PPTX
Java script
Shyam Khant
 
PPT
Introduction to Javascript
Amit Tyagi
 
PPT
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
PPTX
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
PPT
Js ppt
Rakhi Thota
 
Lab #2: Introduction to Javascript
Walid Ashraf
 
JavaScript Programming
Sehwan Noh
 
Java Script ppt
Priya Goyal
 
Java script
Shyam Khant
 
Introduction to Javascript
Amit Tyagi
 
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
Introduction to JavaScript Basics.
Hassan Ahmed Baig - Web Developer
 
Js ppt
Rakhi Thota
 

What's hot (20)

PDF
Javascript basics
shreesenthil
 
PPTX
Javascript event handler
Jesus Obenita Jr.
 
PPT
Javascript
mussawir20
 
PDF
Javascript
Rajavel Dhandabani
 
PDF
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
PPT
Jsp ppt
Vikas Jagtap
 
PPTX
Javascript
Nagarajan
 
PDF
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
PPTX
Java script errors &amp; exceptions handling
AbhishekMondal42
 
PDF
Intro to HTML and CSS basics
Eliran Eliassy
 
PPTX
JavaScript Basics
Bhanuka Uyanage
 
PPTX
Web html table tags
Kainat Ilyas
 
PDF
Basics of JavaScript
Bala Narayanan
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPT
Html forms
M Vishnuvardhan Reddy
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
PPTX
HTML Forms
Ravinder Kamboj
 
PPT
Php forms
Anne Lee
 
PDF
HTML CSS Basics
Mai Moustafa
 
PPT
Web Development using HTML & CSS
Shashank Skills Academy
 
Javascript basics
shreesenthil
 
Javascript event handler
Jesus Obenita Jr.
 
Javascript
mussawir20
 
Javascript
Rajavel Dhandabani
 
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
Jsp ppt
Vikas Jagtap
 
Javascript
Nagarajan
 
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
Java script errors &amp; exceptions handling
AbhishekMondal42
 
Intro to HTML and CSS basics
Eliran Eliassy
 
JavaScript Basics
Bhanuka Uyanage
 
Web html table tags
Kainat Ilyas
 
Basics of JavaScript
Bala Narayanan
 
Methods in Java
Jussi Pohjolainen
 
Html forms
M Vishnuvardhan Reddy
 
The New JavaScript: ES6
Rob Eisenberg
 
HTML Forms
Ravinder Kamboj
 
Php forms
Anne Lee
 
HTML CSS Basics
Mai Moustafa
 
Web Development using HTML & CSS
Shashank Skills Academy
 
Ad

Viewers also liked (20)

PDF
Paris Web - Javascript as a programming language
Marco Cedaro
 
PDF
Javascript Tutorial
Kang-min Liu
 
PDF
The JavaScript Programming Language
guestceb98b
 
KEY
The JavaScript Programming Primer
Mike Wilcox
 
PDF
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
IJSRD
 
PPT
The JavaScript Programming Language
Raghavan Mohan
 
PPTX
JavaScript 101
Mindy McAdams
 
PDF
Reactive Programming with JavaScript
Codemotion
 
PPTX
Introduction to JavaScript Programming
Collaboration Technologies
 
PDF
Functional Programming in JavaScript
Troy Miles
 
PPTX
Biomass gasifier pune
road2ideas
 
PDF
Downdraft biomass gasification: experimental investigation and aspen plus sim...
Antonio Geraldo de Paula Oliveira
 
PPTX
Biomass Gasification presentation
Pritish Shardul
 
PDF
Bio Mass Gasifier
Rochester Institute of Technology
 
PPT
Biomass Gasification
Er Soumyabrata Basak
 
PDF
Biomass heat and power - gasification CHP with universal biomass gasifier
Rado Irgl
 
PPTX
biomass gasification
Akepati S. Reddy
 
PPTX
Biomass gassifier
Aravind Rajan
 
PPSX
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
PDF
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Paris Web - Javascript as a programming language
Marco Cedaro
 
Javascript Tutorial
Kang-min Liu
 
The JavaScript Programming Language
guestceb98b
 
The JavaScript Programming Primer
Mike Wilcox
 
Fabrication and Performance Analysis of Downdraft Biomass Gasifier Using Suga...
IJSRD
 
The JavaScript Programming Language
Raghavan Mohan
 
JavaScript 101
Mindy McAdams
 
Reactive Programming with JavaScript
Codemotion
 
Introduction to JavaScript Programming
Collaboration Technologies
 
Functional Programming in JavaScript
Troy Miles
 
Biomass gasifier pune
road2ideas
 
Downdraft biomass gasification: experimental investigation and aspen plus sim...
Antonio Geraldo de Paula Oliveira
 
Biomass Gasification presentation
Pritish Shardul
 
Biomass Gasification
Er Soumyabrata Basak
 
Biomass heat and power - gasification CHP with universal biomass gasifier
Rado Irgl
 
biomass gasification
Akepati S. Reddy
 
Biomass gassifier
Aravind Rajan
 
DIWE - Programming with JavaScript
Rasan Samarasinghe
 
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Ad

Similar to Introduction to web programming with JavaScript (20)

PPT
Java script
vishal choudhary
 
PPTX
Javascript note for engineering notes.pptx
engineeradda55
 
PDF
Training javascript 2012 hcmut
University of Technology
 
PPTX
JavaScript lesson 1.pptx
MuqaddarNiazi1
 
PPTX
01_JavaScript_Advanced Level_Pratahb.pptx
prathabtwsi
 
PPTX
Welcome to React.pptx
PraveenKumar680401
 
PPTX
JavascriptCOmpleteGuideCourseFromZero.pptx
AlaeddineTheljani
 
PDF
Advanced Java Script.pdf
Sophia Diaz
 
PPTX
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
PPTX
01 Introduction - JavaScript Development
Tommy Vercety
 
PPTX
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
ArjayBalberan1
 
PDF
Fewd week4 slides
William Myers
 
PPTX
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
PPTX
IntroJavascript.pptx cjfjgjggkgutufjf7fjvit8t
SooryaPrashanth1
 
PPT
Html JavaScript and CSS
Radhe Krishna Rajan
 
PDF
Build a game with javascript (april 2017)
Thinkful
 
PPTX
Java script ppt from students in internet technology
SherinRappai
 
PPTX
unit4 wp.pptxjvlbpuvghuigv8ytg2ugvugvuygv
utsavsd11
 
PPTX
An introduction to javascript
tonyh1
 
PPTX
UNIT 1 (7).pptx
DrDhivyaaCRAssistant
 
Java script
vishal choudhary
 
Javascript note for engineering notes.pptx
engineeradda55
 
Training javascript 2012 hcmut
University of Technology
 
JavaScript lesson 1.pptx
MuqaddarNiazi1
 
01_JavaScript_Advanced Level_Pratahb.pptx
prathabtwsi
 
Welcome to React.pptx
PraveenKumar680401
 
JavascriptCOmpleteGuideCourseFromZero.pptx
AlaeddineTheljani
 
Advanced Java Script.pdf
Sophia Diaz
 
Learning About JavaScript (…and its little buddy, JQuery!)
Julie Meloni
 
01 Introduction - JavaScript Development
Tommy Vercety
 
MYSQL DATABASE INTRODUCTION TO JAVASCRIPT.pptx
ArjayBalberan1
 
Fewd week4 slides
William Myers
 
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
IntroJavascript.pptx cjfjgjggkgutufjf7fjvit8t
SooryaPrashanth1
 
Html JavaScript and CSS
Radhe Krishna Rajan
 
Build a game with javascript (april 2017)
Thinkful
 
Java script ppt from students in internet technology
SherinRappai
 
unit4 wp.pptxjvlbpuvghuigv8ytg2ugvugvuygv
utsavsd11
 
An introduction to javascript
tonyh1
 
UNIT 1 (7).pptx
DrDhivyaaCRAssistant
 

Recently uploaded (20)

PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
This slide provides an overview Technology
mineshkharadi333
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 

Introduction to web programming with JavaScript

  • 1. Introduction to web programming with JavaScript #t11sessions
  • 2. T11 Sessions â—Ź A series of workshops, talks and presentations from various practical fields â—Ź Once per month â—Ź Future workshops: Introduction to 3D graphics, Introduction to philosophy etc. â—Ź Inspired by T11, opened for all â—Ź Facebook | [email protected]
  • 3. Discourse and /me â—Ź Been into this thing for ~10 years, but more actively involved last ~5 years â—Ź Happily unemployed â—Ź Don’t expect magic - I’m here to give you some basic knowledge and understanding (nothing is a black box) â—Ź Continuation? â—Ź Ask / Write questions
  • 4. Discourse and /me â—Ź Been into this thing for ~10 years, but more actively involved last ~5 years â—Ź Happily unemployed â—Ź Don’t expect magic - I’m here to give you some basic knowledge and understanding (nothing is a black box) â—Ź Continuation? â—Ź Ask / Write questions â—Ź Task at the end
  • 5. Backend / Frontend web development - what’s up with that? â—Ź Backend development is related mostly to the data, data processing and calculations that are not directly interacting with the user â—Ź Frontend development is related to the elements of a website that are visible to the user and that user interacts with (combination of programming skills and aesthetics)
  • 6. Backend web development - what’s up with that?
  • 7. Frontend web development - what’s up with that?
  • 8. Frontend web development - what’s up with that?
  • 9. HTML (Hyper Text Markup Language) & CSS (Cascading Style Sheets) â—Ź HTML - web programming language that tells web browsers how to structure and present content on a web page (a, p, h1, h2, lists, header, footer, etc) â—Ź CSS - defines a web page’s layout and in order to beautify the page with design elements like colors, rounded corners, gradients, and animation (attached to classes, ids and so on)
  • 10. HTML & CSS <html> <head> <title>Motherfucking Website</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <h1>This is a motherfucking website.</h1> <p class="alert-text">This is a part of '.alert-text' class and it's painted red (color: #FF0000;)</p> <p class="alert-text bold-text">This one extends '.alert-text' but it also adds an additional style</p> </body> </html>
  • 11. HTML & CSS <p class="alert-text">This is a part of '.alert- text' class and it's obviously painted red (color: #FF0000;)</p> .alert-text { color: #FF0000; } This is a part of '.alert-text' class and it's painted red (color: #FF0000;)
  • 12. Hey browser, show me that website! â—Ź Simple scenario: Open your preferable (Chrome, for example) browser, go to a specific website -> http://motherfuckingwebsite.com/
  • 13. Server http://www.mothefuckingwebsite.com Your browser BROWSER MAKES A GET REQUEST TO / RESPONSE (HTML, JS, CSS, IMAGES) USER REQUIRES A www.motherfuckingwebsite.com 46.164.50.177 66.147.244.191
  • 14. index.html style.css main.jsimage.jpg image_1.jpg <script type="text/javascript" src="main.js"></script> <link rel="stylesheet" type="text/css" href="style.css"> <img src=”image.jpg”> <img src=”image_1.jpg”>
  • 15. â—Ź JavaScript is not Java! â—Ź Dynamic programming language most commonly used as part of web websites (interacts with the user, controls the browser, used for games, form validations etc) - basically every website today is using JavaScript â—Ź Simple, easy to read and understand and there’s a lot of resources, which is both good and bad â—Ź No need to setup anything in order to use it JavaScript introduction
  • 16. JavaScript - what exactly is it used for? â—Ź Random calculations (1) â—Ź Animations (1, 2, 3) â—Ź Dynamically change colors and other styles (1, 2) â—Ź Form validations â—Ź Some more heavy shit! (1, 2) â—Ź Dynamically load data
  • 17. Javascript / Browser console â—Ź Chrome / Firefox - right mouse click, then select “Inspect” (or: CTRL + SHIFT + i) â—Ź Examples: Declare a variable, string length, alert(“Hello World!”), select elements, simple calculations, inspect and change element etc. â—Ź copy(someArray.toString());
  • 18. JavaScript overview â—Ź Variables (String, Number, Boolean, Array, Object) â—Ź Operators (+, -, /, *, =, ===, !, !==, &&, ||) â—Ź Events (associated mostly with user behavior) â—Ź Conditionals (if, if else, switch, for, …) â—Ź Functions (built-in functions + custom ones) â—Ź Comments (/* comment */, // comment)
  • 19. JavaScript variables Types: String, Number, Boolean, Array, Object â—Ź Comparable with mathematics (x = 10, y = 1, z = 5) â—Ź var dayOfTheMonth; // declares a variable, undefined â—Ź var dayOfTheMonth = 12; // declares and assigns a variable, Number â—Ź var monthName = "April"; // declares and assigns, String â—Ź var dogs = ["Fluffy", "April", "Archibald"]; // Array â—Ź var person = { firstName: "April", lastName: "June" }; // Object
  • 20. JavaScript operators â—Ź Similar to math â—Ź Basic operators: +, -, /, * â—Ź Assignment operator: = â—Ź Equality operators: ===, !==, <, > â—Ź Logical operators: && (and), || (or) and ! (not)
  • 21. JavaScript logical operators â—Ź And (&&) â—‹ true && true == true â—‹ true && false == false â—‹ false && true == false â—‹ false && false == false â—Ź Or (||) â—‹ true || true == true â—‹ true || false == true â—‹ false || true == true â—‹ false || false == false â—Ź Not (!) â—‹ !true == false â—‹ !false == true
  • 22. JavaScript logical operators â—Ź And (&&) â—‹ true && true == true â—‹ true && false == false â—‹ false && true == false â—‹ false && false == false â—Ź Or (||) â—‹ true || true == true â—‹ true || false == true â—‹ false || true == true â—‹ false || false == false â—Ź Not (!) â—‹ !true == false â—‹ !false == true
  • 23. JavaScript events â—Ź Completely related to web development, and user behavior â—Ź You can define what to do when user clicks on a specific button, selects an a different value in dropdown, gets focus into a specific element and so on â—Ź You can register them either in HTML or in JS
  • 24. JavaScript statements (if) var yourName = prompt("Please enter your name", ""); // gets the entered name // if you don't provide a name, you'll become "Anonymous" if (yourName === '') { yourName = 'Anonymous'; }
  • 25. JavaScript statements (if else) var yourName = prompt("Please enter your name", ""); // gets the entered name // if you don't provide a name, you'll become "Anonymous" if (yourName === '') { yourName = 'Anonymous'; } else if (yourName === 'Barack Obama') { yourName = 'Anonymous'; }
  • 26. JavaScript statements (switch) var yourName = prompt("Please enter your name", ""); // gets the entered name switch (yourName) { case '': yourName = 'Anonymous'; break; case 'Barack Obama': yourName = 'Anonymous'; break; default: // all other cases // don’t do anything }
  • 27. JavaScript statements (for) var dogs = ["Fluffy", "April", "Archibald"]; // array of dogs // prints out all the dogs for (var i = 0; i < dogs.length; i++) { alert(dogs[i]); } 0 1 2
  • 28. JavaScript statements (while) var dogs = ["Fluffy", "April", "Archibald"]; // array of dogs // does the same as for loop var i = 0; while (i < dogs.length) { alert(dogs[i]); i++; } 0 1 2
  • 29. JavaScript functions â—Ź Closely connected with mathematics â—Ź Built in functions (String has length, substring, text can be converted into Number etc) â—Ź Custom functions (write whatever you want)
  • 30. JavaScript functions (examples) Math x2 (x - input) x+y (x, y - inputs) x + y / z (x, y, z - inputs) JavaScript function square(x) { return x*x; } function addition(x, y) { return x + y; } function randomFormula(x, y, z) { return (x + y) / z; } JavaScript call square(2); // 4 addition(4,4); // 8 randomFormula(5,5,2); // 5
  • 31. JavaScript functions (examples) Math F = 9/5 * C + 32 (C - input) C = 5/9 * (F - 32) (F - input) D = b2 - 4*a*c JavaScript function celsiusToFahrenheit(celsius) { return ((9 / 5) * celsius) + 32; } function fahrenheitToCelsius(fahrenheit) { return (5 / 9) * (fahrenheit - 32); } function discriminant(a, b, c) { return Math.pow(b,2) - (4 * a * c); } JavaScript call celsiusToFahrenheit(30); // 86 fahrenheitToCelsius(77); // 25 discriminant(2,2,2); // -12
  • 32. JavaScript vs. jQuery â—Ź jQuery is basically just a wrapper for JavaScript, that simplifies and beautifies the code â—Ź document.getElementById(“test”) -> $(“#test”) â—Ź document.getElementsByClassName(“test”) -> $(“.test”) â—Ź Can be useful, but don’t rush :)
  • 33. Tools â—Ź For writing code: Sublime Text or Atom or Notepad++ â—Ź Write code online: JSFiddle â—Ź Web browser by choice (recommendation: Chrome) and browser console â—Ź Versioning: Git and Github â—Ź Simple Python server (for later use)
  • 34. Where and how to continue? â—Ź Codecademy (1, 2, 3, 4, overview) â—Ź Coursera (1, 2, 3, 4, 5) â—Ź Quick tutorials and exercises (1, 2, 3) â—Ź 20 things I’ve learned about browsers and web â—Ź Random JavaScript examples (1, 2, 3) â—Ź Start your own project! â—Ź Real life courses (1) â—Ź Google, a lot! Beware: you’ll find a lot of bad examples online
  • 35. Tasks - how to deal with it? â—Ź Download .zip file â—‹ index.html â—‹ style.css â—‹ main.js â—‹ images/image.jpg â—‹ images/image_1.jpg
  • 36. Tasks - how to deal with it? â—Ź Download .zip file â—Ź Export files to /home/dev/t11sessions or similar directory â—Ź Get Sublime Text or similar text/code editor â—Ź Open index.html in Sublime Text and in preferable browser (Open with…, then select preferable app) â—Ź Observe index.html (both code and browser), try to change/update things and go through TODO tasks â—Ź Open main.js and style.css, read comments and TODO tasks
  • 37. Thanks for your attention [email protected] @dperitch

Editor's Notes

  • #10: Show html/css examples
  • #11: Show html/css examples
  • #12: Show html/css examples
  • #16: It’s simple, easy to read and understand (“old-school” syntax) and there’s a lot of resources, which is both good and bad - think of that as a shared house where ten individuals haven’t agreed upon any specific rules (chores, cleaning, noise etc.)
  • #23: If (yourAge >= 18 && yourAge < 50) { // pass }