SlideShare une entreprise Scribd logo
1  sur  72
Télécharger pour lire hors ligne
JavaScript
for Beginners
@ssaunier
{ , }/ssaunier
Sébastien Saunier
CTO @ Le Wagon
Bring technical skills
to creative people
Let's talk about JavaScript
In-browser language
(since 1995)
Sublime Text
JS Bin
Data types
typeof
Numbers
-100
0
1
3.14
42
Boolean
true
false
String
"John"
"John Lennon"
"a"
""
Object
{
"first_name" : "John",
"last_name" : "Lennon"
}
[ "john", "paul", "ringo", "george" ]
null
undefined
Variables
var
var firstName;
var firstName = "John";
"John"
console.log(firstName);
"John"
Concatenate two strings
Exercise
Conditions
if, else
if (weather === "rainy") {
console.log("Take an umbrella");
}
if (weather === "rainy") {
console.log("Take an umbrella");
} else {
console.log("Take your sunglasses");
}
if (weather === "rainy") {
console.log("Take an umbrella");
} else if (weather === "stormy") {
console.log("Stay at home");
} else {
console.log("Take your sunglasses");
}
Boolean algebra
&&, ||, !
var result = a && b;
Logical and
a b result
false false false
false true false
true false false
true true true
var rain = true;
var wind = true;
if (rain && wind) {
console.log("Really stay at home");
}
var result = a || b;
Logical or
a b result
false false false
false true true
true false true
true true true
var day = "Saturday";
if (day === "Saturday" || day === "Sunday") {
console.log("It's the week-end!");
}
var result = !a;
Logical not
a result
true false
false true
var sunny = true;
if (!sunny) {
console.log("Cancel the beach");
}
var weather = "raining";
if (weather !== "sunny") {
console.log("Cancel the beach");
}
Filter names starting with a "B"
Exercise
Loops
for, while
Array
var students = [ "john", "paul", "ringo" ];
students.length // => 3
students[0] // => "john"
students[2] // => "ringo"
students[1] // => "paul"
For
for (var i = 0; i < students.length; i += 1) {
console.log(students[i]);
}
Filter names starting with a "B"
Exercise bis
While
var i = 0;
while (i < students.length) {
console.log(students[i]);

i += 1;
}
Functions
function
function name(parameters) {
body
(return statement)
}
function fullName(first, last) {
var name = first + " " + last;
return name;
}
Example: Full Name
fullName("John", "Lennon");
Calling a function
Function name arguments
Filter names starting with "B"
starting with "C"
…
Exercise ter
DOM
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>
Hello
</h1>
<p>
Lorem Ipsum…
</p>
</body>
</html>
html
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>
Hello
</h1>
<p>
Lorem Ipsum…
</p>
</body>
</html>
html
head body
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>
Hello
</h1>
<p>
Lorem Ipsum…
</p>
</body>
</html>
html
head body
title
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>
Hello
</h1>
<p>
Lorem Ipsum…
</p>
</body>
</html>
html
head body
title h1 p
jQuery
https://code.jquery.com/jquery-1.11.3.min.js
$(document).ready(function() {
// The jQuery-dependent code
});
1 - DOM Manipulation
p
$("p").hide();
<h1>
Hello
</h1>
<p>
Lorem Ipsum…
</p>
<p>
Autrum Ipsum…
</p>
Element Selector
#cart
$("#cart").hide();
<h1>
Hello
</h1>
<div id="cart">
[…]
</div>
<div>
[…]
</div>
Id selector
.red
$(".red").hide();
<div class="green">
Hello
</h1>
<div class="red">
[…]
</div>
<div class="red">
[…]
</div>
Class selector
<div id="cart" class="red">
[…]
</div>
$("#cart").addClass(‘bold’);
<div id="cart" class="red">
[…]
</div>
$("#cart").addClass(‘bold’);
<div id="cart" class="red">
[…]
</div>
<div id="cart" class="bold red">
[…]
</div>
$("#cart").removeClass(‘bold’);
<div id="cart" class="bold red">
[…]
</div>
<div id="cart" class="red">
[…]
</div>
2 - Event Handling
$('#play-button').click();
$('#an-element').on('click', function() {
alert("You have clicked");
});
3 - AJAX
(To be continued…)
Resources
ondemand.lewagon.org/jsmeetup
-30€
(Jusqu'à dimanche, 23h)

Contenu connexe

Tendances

Tendances (20)

Flask Basics
Flask BasicsFlask Basics
Flask Basics
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
Le Wagon - React 101
Le Wagon - React 101Le Wagon - React 101
Le Wagon - React 101
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Flask
FlaskFlask
Flask
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, Tricks
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Git
GitGit
Git
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Javascript
JavascriptJavascript
Javascript
 
HTML X CSS
HTML X CSSHTML X CSS
HTML X CSS
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Flutter 3
Flutter 3Flutter 3
Flutter 3
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react js
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 

Similaire à Le Wagon - Javascript for Beginners

Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
Simon Willison
 

Similaire à Le Wagon - Javascript for Beginners (20)

Le wagon - JavaScript for beginners
Le wagon - JavaScript for beginnersLe wagon - JavaScript for beginners
Le wagon - JavaScript for beginners
 
Meetup Javascript for beginner
Meetup Javascript for beginner Meetup Javascript for beginner
Meetup Javascript for beginner
 
Le wagon javascript for beginners - ARF
Le wagon   javascript for beginners - ARFLe wagon   javascript for beginners - ARF
Le wagon javascript for beginners - ARF
 
Javascript development done right
Javascript development done rightJavascript development done right
Javascript development done right
 
JavaScript Survival Guide
JavaScript Survival GuideJavaScript Survival Guide
JavaScript Survival Guide
 
JavaScript - Like a Box of Chocolates
JavaScript - Like a Box of ChocolatesJavaScript - Like a Box of Chocolates
JavaScript - Like a Box of Chocolates
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
 
Introduction to ECMAScript 2015
Introduction to ECMAScript 2015Introduction to ECMAScript 2015
Introduction to ECMAScript 2015
 
Introduction kot iin
Introduction kot iinIntroduction kot iin
Introduction kot iin
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlin
 
Swift Study #7
Swift Study #7Swift Study #7
Swift Study #7
 
Bologna Developer Zone - About Kotlin
Bologna Developer Zone - About KotlinBologna Developer Zone - About Kotlin
Bologna Developer Zone - About Kotlin
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlin
 
Start Writing Groovy
Start Writing GroovyStart Writing Groovy
Start Writing Groovy
 
Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015Pooya Khaloo Presentation on IWMC 2015
Pooya Khaloo Presentation on IWMC 2015
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile database
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
 

Dernier

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Dernier (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 

Le Wagon - Javascript for Beginners