SlideShare a Scribd company logo
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)
Le Wagon - Javascript for Beginners
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
Le Wagon - Javascript for Beginners
Le Wagon - Javascript for Beginners
Le Wagon - Javascript for Beginners
Le Wagon - Javascript for Beginners
<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
Le Wagon - Javascript for Beginners
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
Le Wagon - Javascript for Beginners
Le Wagon - Javascript for Beginners
Le Wagon - Javascript for Beginners
Le Wagon - Javascript for Beginners
ondemand.lewagon.org/jsmeetup
-30€
(Jusqu'à dimanche, 23h)

More Related Content

PDF
Le Wagon - UI components design
PDF
Git & GitHub for Beginners
PDF
API for Beginners
PDF
Le Wagon - Web 101
PDF
Le Wagon - 2h Landing
PDF
Git training v10
PPTX
Git presentation
PPTX
Computer Hardware
Le Wagon - UI components design
Git & GitHub for Beginners
API for Beginners
Le Wagon - Web 101
Le Wagon - 2h Landing
Git training v10
Git presentation
Computer Hardware

What's hot (20)

PDF
Techical Workflow for a Startup
PDF
Le Wagon - UI and Design Crash Course
PPT
Collections Framework
PDF
The JavaScript Programming Language
PDF
Spring boot
PDF
Spring Boot
PPT
Log4 J
PDF
Flask Introduction - Python Meetup
PPT
Java 8 - CJ
PPT
JAVA OOP
PDF
Try Jetpack Compose
PDF
Spring annotation
PPTX
Express JS
PPT
Spring Boot in Action
PPS
Introduction to Bootstrap: Design for Developers
PDF
Kotlin Coroutines in Practice @ KotlinConf 2018
PPTX
Kotlin
PDF
Android Developer JeongJaeyun
PPTX
Spring data jpa
PDF
Declarative UIs with Jetpack Compose
Techical Workflow for a Startup
Le Wagon - UI and Design Crash Course
Collections Framework
The JavaScript Programming Language
Spring boot
Spring Boot
Log4 J
Flask Introduction - Python Meetup
Java 8 - CJ
JAVA OOP
Try Jetpack Compose
Spring annotation
Express JS
Spring Boot in Action
Introduction to Bootstrap: Design for Developers
Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin
Android Developer JeongJaeyun
Spring data jpa
Declarative UIs with Jetpack Compose
Ad

Similar to Le Wagon - Javascript for Beginners (20)

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

Recently uploaded (20)

PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
102 student loan defaulters named and shamed – Is someone you know on the list?
Week 4 Term 3 Study Techniques revisited.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
STATICS OF THE RIGID BODIES Hibbelers.pdf
Final Presentation General Medicine 03-08-2024.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial disease of the cardiovascular and lymphatic systems
TR - Agricultural Crops Production NC III.pdf
Insiders guide to clinical Medicine.pdf
Complications of Minimal Access Surgery at WLH
PPH.pptx obstetrics and gynecology in nursing
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Supply Chain Operations Speaking Notes -ICLT Program
VCE English Exam - Section C Student Revision Booklet
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf

Le Wagon - Javascript for Beginners