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
PDF
Web develop in flask
PDF
Le Wagon Tokyo - 2 hours landing page
PPTX
Introduction to PHP
PDF
Introduction to Bootstrap
PPT
Hibernate
PDF
Intro to Jinja2 Templates - San Francisco Flask Meetup
PPT
Introduction To PHP
PPT
Bootstrap Components Quick Overview
PDF
Google Cheat Sheet
PDF
The JavaScript Programming Language
PPT
Learning Html
PDF
CSS Dasar #5 : Text Styling
PDF
CSS Grid Layout Introduction
PDF
Redux Toolkit - Quick Intro - 2022
PDF
CSS Dasar #6 : Background
ODP
Json Tutorial
PPTX
Owl: The New Odoo UI Framework
PDF
Redux toolkit
Techical Workflow for a Startup
Le Wagon - UI and Design Crash Course
Web develop in flask
Le Wagon Tokyo - 2 hours landing page
Introduction to PHP
Introduction to Bootstrap
Hibernate
Intro to Jinja2 Templates - San Francisco Flask Meetup
Introduction To PHP
Bootstrap Components Quick Overview
Google Cheat Sheet
The JavaScript Programming Language
Learning Html
CSS Dasar #5 : Text Styling
CSS Grid Layout Introduction
Redux Toolkit - Quick Intro - 2022
CSS Dasar #6 : Background
Json Tutorial
Owl: The New Odoo UI Framework
Redux toolkit
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
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Institutional Correction lecture only . . .
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Cell Structure & Organelles in detailed.
PPTX
Presentation on HIE in infants and its manifestations
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Lesson notes of climatology university.
PDF
RMMM.pdf make it easy to upload and study
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Supply Chain Operations Speaking Notes -ICLT Program
O7-L3 Supply Chain Operations - ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Final Presentation General Medicine 03-08-2024.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Institutional Correction lecture only . . .
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Microbial diseases, their pathogenesis and prophylaxis
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Cell Structure & Organelles in detailed.
Presentation on HIE in infants and its manifestations
A systematic review of self-coping strategies used by university students to ...
O5-L3 Freight Transport Ops (International) V1.pdf
Lesson notes of climatology university.
RMMM.pdf make it easy to upload and study

Le Wagon - Javascript for Beginners