SlideShare a Scribd company logo
1 of 72
Download to read offline
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)

More Related Content

What's hot

JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 

What's hot (20)

Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytest
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
CSS
CSSCSS
CSS
 
Java 8-streams-collectors-patterns
Java 8-streams-collectors-patternsJava 8-streams-collectors-patterns
Java 8-streams-collectors-patterns
 
SWTBot Tutorial
SWTBot TutorialSWTBot Tutorial
SWTBot Tutorial
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Shaping Up Theme Roller Beyond Universal Theme
Shaping Up Theme Roller Beyond Universal ThemeShaping Up Theme Roller Beyond Universal Theme
Shaping Up Theme Roller Beyond Universal Theme
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
Basic HTML CSS Slides
Basic HTML CSS Slides Basic HTML CSS Slides
Basic HTML CSS Slides
 
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
How to steal and modify data using Business Logic flaws - Insecure Direct Obj...
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Le Wagon - React 101
Le Wagon - React 101Le Wagon - React 101
Le Wagon - React 101
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Log4 J
Log4 JLog4 J
Log4 J
 
Hibernate
Hibernate Hibernate
Hibernate
 

Similar to 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
 

Similar to 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
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
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
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 

Le Wagon - Javascript for Beginners