SlideShare une entreprise Scribd logo
1  sur  47
Télécharger pour lire hors ligne
Javascript : Valeurs, types & opérateurs
1. Un programme javascript
1.1 Outils
Moteurs JavaScript pour le développement 
Navigateur Console JSFiddle
Les outils du développeur Javascript (1) 
FireFox Chrome Chrome Canary
Les outils du développeur Javascript (2) 
Atom.io Sublime Text Brackets
1.2 code javascript ?
Un fichier javascript 
alert("Bazinga"); 
alert("Im not crazy."); 
alert("My mother had me tested");
Quelques commandes 
alert("Suit up!"); 
console.log("Haaaaaave you met Ted?");
Commentaires 
// Single Line Comments 
! 
/* 
Multi-line 
Comments 
*/
1.3 Où mettre du javascript ?
JavaScript dans une page HTML (1) 
<!doctype html> 
<html> 
<head></head> 
<body> 
<script> 
alert('Hello world!'); 
</script> 
</body> 
</html>
JavaScript dans une page HTML (2) 
<!doctype html> 
<html> 
<head></head> 
<body> 
<script src="hello.js"></script> 
</body> 
</html>
2. Valeurs
2.1 Nombres
Définir un nombre 
890 // entier 
87.90 // décimal 
2.9e3 // 2.9 * 10 * 10 * 10
Maximum & minimum (1) 
[-253 … 253]
Maximum & minimum (2) 
9007199254740992 + 1 == 9007199254740992; // true 
0.2 + 0.4 == 0.6000000000000001; // true 
1/7 + 1/7 + 1/7 + 1/7 + 1/7 + 1/7 + 1/7 != 1; // true
Nombres spéciaux (1) 
Infinity // plus l'infini 
-Infinity // moins l'infini 
NaN // Not a Number
Nombres spéciaux (2) 
Infinity + 1 == Infinity // true 
Infinity - Infinity == NaN // true 
0/0 == NaN // true 
NaN + 1 == NaN // true
2.2 Chaînes de caractères
Définir une chaîne de caractères 
"When I get sad I stop being sad and be AWESOME instead." 
'True story!'
Caractère d'échappement 
"There is only one god and his name is Death. And 
there is only one thing we say to Death: "Not today."" 
! 
"A bear there was, a bear, a bear!n 
All black and brown, and covered with hair!n 
The bear! The bear!n 
Oh, come, they said, oh come to the fair!n 
The fair? Said he, but I'm a bear!n 
All black, and brown, and covered with hair!" 
! 
"hodor  hodor  hodor"
2.3 valeurs spéciales
Booléens 
true != false // true 
true == 1; // true 
false == 0; // true
Null & Undefined (1) 
Undefined : primitive value used when a variable has not 
been assigned a value 
Null : primitive value that represents the intentional 
absence of any object value
Null & Undefined (2) 
undefined == null // true 
undefined != 0 // true 
null != 0 // true
3. Opérateurs
3.1 Manipulation
Arithmétique 
3 + 2 == 5; 
3 - 2 == 1; 
3 * 2 == 6; 
3 / 2 == 1.5; 
3 % 2 == 1; 
! 
3 * 2 + 2 == 8;
Concaténation 
"If you're committed enough, you can make any story 
work." + " I once told a woman I was Kevin Costner, and 
it worked because I believed it." + " - Saul Goodman »; 
! 
// If you're committed enough, you can make any story 
work. I once told a woman I was Kevin Costner, and it 
worked because I believed it - Saul Goodman
3.2 Comparaison
Numérique 
3 > 2 // true 
3 < 2 // false 
8 == 9 // false 
8 != 9 // true 
9 >= 9 // true 
9 <= 10 // true 
! 
9 == '9' // true 
9 === '9' // false 
! 
'a' < 'u' // true; 
'ab' < 'ba' // true 
'a' < 'Z' // false
Logique 
true && true // true 
true && false // false 
false && false // false 
! 
true || true // true 
true || false // true 
false || false // false 
! 
!true // false 
!false // true 
! 
3 + 4 == 7 && 2 * 8 > 10 // true
Ternaire 
true ? 'yep' : 'nop' // yep 
false ? 'yeah' : 'noop' // noop
3.3 Types & transformations
Types de données 
typeof 8 // number 
typeof 9.3 // number 
typeof NaN // number 
typeof 'toto' // string 
typeof true // boolean 
typeof null // object 
typeof undefined // undefined
Conversion de type 
3 * null // 0 
"3" - 1 // 2 
"3" + 1 // 4 
"cinq" * 3 // NaN 
"five" * 3 // NaN 
false == 0 // true
4. Constantes & Variables
Nommer une variable (1) 
Aucun espace 
Aucun mots clés réservés : break case catch continue 
debugger default delete do else false finally for function if 
implements in instanceof interface let new null package 
private protected public return static switch throw true 
try typeof var void while with yield this 
Aucune ponctuation sauf ‘_’ et ‘$’ 
Ne doit pas commencer par un chiffre
Nommer une variable (2) 
// Syntax valide 
var a; 
var b, c; 
var s_variable; 
var b2; 
// Syntax invalide 
var 2a; 
var a:a; 
var function;
Affecter une variable 
// Affecter une variable 
var a = 8, b = "toto", c = true, d; 
a = 2; 
console.log(a); // 2 
console.log(b); // toto 
console.log(c); // true 
console.log(d); // undefined
Constantes 
const a = 8; 
a = 2; 
console.log(a); // 8
Merci pour votre attention.
Bibliographie 
Eloquent JavaScript - Marijn Haverbeke 
http://eloquentjavascript.net 
Dynamisez vos sites web avec Javascript ! - Johann Pardanaud & Sébastien de la Marck 
http://fr.openclassrooms.com/informatique/cours/dynamisez-vos-sites-web-avec-javascript 
JavaScript Fundamentals - Jeremy McPeak 
http://code.tutsplus.com/courses/javascript-fundamentals 
Guide JavaScript - teoli, BenoitL, delislejm, Ame_Nomade, SphinxKnight 
https://developer.mozilla.org/fr/docs/Web/JavaScript/Guide 
Javascript – MAX_INT: Number Limits - Vjeux 
http://blog.vjeux.com/2010/javascript/javascript-max_int-number-limits.html
Crédits (1) 
Lost - Jeffrey Lieber, J. J. Abrams, Damon Lindelof 
http://abc.go.com/shows/lost 
Person of interest - Jonathan Nolan, David Slack, Patrick Harbinson 
http://www.cbs.com/shows/person_of_interest/ 
Halt and Catch Fire - Christopher Cantwell, Christopher C. Rogers 
http://www.amctv.com/shows/halt-and-catch-fire 
Utilities terminal Icon - kxmylo 
http://www.iconarchive.com/show/simple-icons-by-kxmylo/utilities-terminal-icon.html 
Breaking bad - Vince Gilligan 
http://www.amctv.com/shows/breaking-bad 
House of Cards - Beau Willimon 
https://www.facebook.com/HouseofCards 
The Big Bang Theory - Chuck Lorre, Bill Prady 
http://www.cbs.com/shows/big_bang_theory/ 
Game of Thrones - David Benioff, D. B. Weiss 
http://www.hbo.com/game-of-thrones
The Wire - David Simon 
http://www.hbo.com/the-wire 
Crédits (2) 
Silicon Valley - Mike Judge 
http://www.hbo.com/silicon-valley 
The Killing - Veena Sud 
http://www.amctv.com/shows/the-killing 
Band of Brothers - Tom Hanks, Steven Spielberg 
http://www.hbo.com/band-of-brothers

Contenu connexe

Tendances

JavaScript pour les développeurs .NET
JavaScript pour les développeurs .NETJavaScript pour les développeurs .NET
JavaScript pour les développeurs .NETThomas Conté
 
Political Science For Dummies!
Political Science For Dummies!Political Science For Dummies!
Political Science For Dummies!hhaghdadi
 
Membuat bootable usb flash disk untuk windows 7 dan windows xp
Membuat bootable usb flash disk untuk windows 7 dan windows xpMembuat bootable usb flash disk untuk windows 7 dan windows xp
Membuat bootable usb flash disk untuk windows 7 dan windows xpwardi Unigha
 

Tendances (8)

JavaScript pour les développeurs .NET
JavaScript pour les développeurs .NETJavaScript pour les développeurs .NET
JavaScript pour les développeurs .NET
 
Bash bonnes pratiques
Bash bonnes pratiquesBash bonnes pratiques
Bash bonnes pratiques
 
Political Science For Dummies!
Political Science For Dummies!Political Science For Dummies!
Political Science For Dummies!
 
Cours php
Cours phpCours php
Cours php
 
Membuat bootable usb flash disk untuk windows 7 dan windows xp
Membuat bootable usb flash disk untuk windows 7 dan windows xpMembuat bootable usb flash disk untuk windows 7 dan windows xp
Membuat bootable usb flash disk untuk windows 7 dan windows xp
 
การสร้างและการเพิ่มสไลด์
การสร้างและการเพิ่มสไลด์การสร้างและการเพิ่มสไลด์
การสร้างและการเพิ่มสไลด์
 
exch2003
exch2003exch2003
exch2003
 
Utah PMA Quarterly Meeting Intro, March, 2009
Utah PMA Quarterly Meeting Intro, March, 2009Utah PMA Quarterly Meeting Intro, March, 2009
Utah PMA Quarterly Meeting Intro, March, 2009
 

En vedette

Javascript #9 : barbarian quest
Javascript #9 : barbarian questJavascript #9 : barbarian quest
Javascript #9 : barbarian questJean Michel
 
Gestion de projet #4 : spécification
Gestion de projet #4 : spécificationGestion de projet #4 : spécification
Gestion de projet #4 : spécificationJean Michel
 
WebApp #4 : Consuming REST APIs
WebApp #4 : Consuming REST APIs WebApp #4 : Consuming REST APIs
WebApp #4 : Consuming REST APIs Jean Michel
 
Javascript #10 : canvas
Javascript #10 : canvasJavascript #10 : canvas
Javascript #10 : canvasJean Michel
 
PHP #7 : guess who?
PHP #7 : guess who?PHP #7 : guess who?
PHP #7 : guess who?Jean Michel
 
Wordpress #2 : customisation
Wordpress #2 : customisationWordpress #2 : customisation
Wordpress #2 : customisationJean Michel
 
PHP #4 : sessions & cookies
PHP #4 : sessions & cookiesPHP #4 : sessions & cookies
PHP #4 : sessions & cookiesJean Michel
 
Startup & entrepreneuriat #2.1: disrupt me
Startup & entrepreneuriat #2.1: disrupt meStartup & entrepreneuriat #2.1: disrupt me
Startup & entrepreneuriat #2.1: disrupt meJean Michel
 
Architecture logicielle #5 : hipsto framework
Architecture logicielle #5 : hipsto frameworkArchitecture logicielle #5 : hipsto framework
Architecture logicielle #5 : hipsto frameworkJean Michel
 
PHP #3 : tableaux & formulaires
PHP #3 : tableaux & formulairesPHP #3 : tableaux & formulaires
PHP #3 : tableaux & formulairesJean Michel
 
Javascript #8 : événements
Javascript #8 : événementsJavascript #8 : événements
Javascript #8 : événementsJean Michel
 
Wordpress #3 : content strategie
Wordpress #3 : content strategieWordpress #3 : content strategie
Wordpress #3 : content strategieJean Michel
 
Javascript #2.2 : jQuery
Javascript #2.2 : jQueryJavascript #2.2 : jQuery
Javascript #2.2 : jQueryJean Michel
 
Gestion de projet #3 : besoin client
Gestion de projet #3 : besoin clientGestion de projet #3 : besoin client
Gestion de projet #3 : besoin clientJean Michel
 
Javascript #4.1 : fonctions for noobs
Javascript #4.1 : fonctions for noobsJavascript #4.1 : fonctions for noobs
Javascript #4.1 : fonctions for noobsJean Michel
 
PHP & MYSQL #5 : fonctions
PHP & MYSQL #5 :  fonctionsPHP & MYSQL #5 :  fonctions
PHP & MYSQL #5 : fonctionsJean Michel
 
#3 html in the real world
#3 html in the real world#3 html in the real world
#3 html in the real worldJean Michel
 
WebApp #2 : responsive design
WebApp #2 : responsive designWebApp #2 : responsive design
WebApp #2 : responsive designJean Michel
 
Wordpress #1 : introduction
Wordpress #1 : introductionWordpress #1 : introduction
Wordpress #1 : introductionJean Michel
 
Javascript #3 : boucles & conditions
Javascript #3 : boucles & conditionsJavascript #3 : boucles & conditions
Javascript #3 : boucles & conditionsJean Michel
 

En vedette (20)

Javascript #9 : barbarian quest
Javascript #9 : barbarian questJavascript #9 : barbarian quest
Javascript #9 : barbarian quest
 
Gestion de projet #4 : spécification
Gestion de projet #4 : spécificationGestion de projet #4 : spécification
Gestion de projet #4 : spécification
 
WebApp #4 : Consuming REST APIs
WebApp #4 : Consuming REST APIs WebApp #4 : Consuming REST APIs
WebApp #4 : Consuming REST APIs
 
Javascript #10 : canvas
Javascript #10 : canvasJavascript #10 : canvas
Javascript #10 : canvas
 
PHP #7 : guess who?
PHP #7 : guess who?PHP #7 : guess who?
PHP #7 : guess who?
 
Wordpress #2 : customisation
Wordpress #2 : customisationWordpress #2 : customisation
Wordpress #2 : customisation
 
PHP #4 : sessions & cookies
PHP #4 : sessions & cookiesPHP #4 : sessions & cookies
PHP #4 : sessions & cookies
 
Startup & entrepreneuriat #2.1: disrupt me
Startup & entrepreneuriat #2.1: disrupt meStartup & entrepreneuriat #2.1: disrupt me
Startup & entrepreneuriat #2.1: disrupt me
 
Architecture logicielle #5 : hipsto framework
Architecture logicielle #5 : hipsto frameworkArchitecture logicielle #5 : hipsto framework
Architecture logicielle #5 : hipsto framework
 
PHP #3 : tableaux & formulaires
PHP #3 : tableaux & formulairesPHP #3 : tableaux & formulaires
PHP #3 : tableaux & formulaires
 
Javascript #8 : événements
Javascript #8 : événementsJavascript #8 : événements
Javascript #8 : événements
 
Wordpress #3 : content strategie
Wordpress #3 : content strategieWordpress #3 : content strategie
Wordpress #3 : content strategie
 
Javascript #2.2 : jQuery
Javascript #2.2 : jQueryJavascript #2.2 : jQuery
Javascript #2.2 : jQuery
 
Gestion de projet #3 : besoin client
Gestion de projet #3 : besoin clientGestion de projet #3 : besoin client
Gestion de projet #3 : besoin client
 
Javascript #4.1 : fonctions for noobs
Javascript #4.1 : fonctions for noobsJavascript #4.1 : fonctions for noobs
Javascript #4.1 : fonctions for noobs
 
PHP & MYSQL #5 : fonctions
PHP & MYSQL #5 :  fonctionsPHP & MYSQL #5 :  fonctions
PHP & MYSQL #5 : fonctions
 
#3 html in the real world
#3 html in the real world#3 html in the real world
#3 html in the real world
 
WebApp #2 : responsive design
WebApp #2 : responsive designWebApp #2 : responsive design
WebApp #2 : responsive design
 
Wordpress #1 : introduction
Wordpress #1 : introductionWordpress #1 : introduction
Wordpress #1 : introduction
 
Javascript #3 : boucles & conditions
Javascript #3 : boucles & conditionsJavascript #3 : boucles & conditions
Javascript #3 : boucles & conditions
 

Similaire à Javascript #2 : valeurs, types & opérateurs

Javascript : que fait ce code?
Javascript : que fait ce code?Javascript : que fait ce code?
Javascript : que fait ce code?Ruau Mickael
 
Beyond F5 - windbg et .Net
Beyond F5 - windbg et .NetBeyond F5 - windbg et .Net
Beyond F5 - windbg et .NetYann Schwartz
 
Javascript pour les développeurs Java : quels sont les pièges à éviter ?
Javascript pour les développeurs Java : quels sont les pièges à éviter ?Javascript pour les développeurs Java : quels sont les pièges à éviter ?
Javascript pour les développeurs Java : quels sont les pièges à éviter ?FlorianBoulay
 
Bases de PHP - Partie 1
Bases de PHP - Partie 1Bases de PHP - Partie 1
Bases de PHP - Partie 1Régis Lutter
 
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINEIntroduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINEMarouan OMEZZINE
 
Future of java script web version
Future of java script web versionFuture of java script web version
Future of java script web versionSébastien Pertus
 
Introduction à JavaScript
Introduction à JavaScriptIntroduction à JavaScript
Introduction à JavaScriptMicrosoft
 
Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...
Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...
Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...ATPENSC-Group
 
Fondamentaux portée - contexte - function ms tech days
Fondamentaux   portée - contexte - function ms tech daysFondamentaux   portée - contexte - function ms tech days
Fondamentaux portée - contexte - function ms tech daysJean-Pierre Vincent
 
Librairies Java qui changent la vie
Librairies Java qui changent la vieLibrairies Java qui changent la vie
Librairies Java qui changent la viecluelessjoe
 
Nouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde MicrosoftNouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde Microsoftdavrous
 
Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?
Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?
Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?Institut Pasteur de Madagascar
 
Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Aurélien Maury
 

Similaire à Javascript #2 : valeurs, types & opérateurs (20)

Cours javascript v1
Cours javascript v1Cours javascript v1
Cours javascript v1
 
PHP.pptx
PHP.pptxPHP.pptx
PHP.pptx
 
Cours php
Cours phpCours php
Cours php
 
Les bases du javascript
Les bases du javascriptLes bases du javascript
Les bases du javascript
 
Javascript : que fait ce code?
Javascript : que fait ce code?Javascript : que fait ce code?
Javascript : que fait ce code?
 
Beyond F5 - windbg et .Net
Beyond F5 - windbg et .NetBeyond F5 - windbg et .Net
Beyond F5 - windbg et .Net
 
Javascript pour les développeurs Java : quels sont les pièges à éviter ?
Javascript pour les développeurs Java : quels sont les pièges à éviter ?Javascript pour les développeurs Java : quels sont les pièges à éviter ?
Javascript pour les développeurs Java : quels sont les pièges à éviter ?
 
Ruby Pour RoR
Ruby Pour RoRRuby Pour RoR
Ruby Pour RoR
 
Bases de PHP - Partie 1
Bases de PHP - Partie 1Bases de PHP - Partie 1
Bases de PHP - Partie 1
 
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINEIntroduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
Introduction au langage PHP (1ere partie) élaborée par Marouan OMEZZINE
 
Future of java script web version
Future of java script web versionFuture of java script web version
Future of java script web version
 
Introduction à JavaScript
Introduction à JavaScriptIntroduction à JavaScript
Introduction à JavaScript
 
La première partie de la présentation PHP
La première partie de la présentation PHPLa première partie de la présentation PHP
La première partie de la présentation PHP
 
Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...
Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...
Fiche de TD 1 de préparation probatoire (littéraire et scientifique) du Camer...
 
Fondamentaux portée - contexte - function ms tech days
Fondamentaux   portée - contexte - function ms tech daysFondamentaux   portée - contexte - function ms tech days
Fondamentaux portée - contexte - function ms tech days
 
Librairies Java qui changent la vie
Librairies Java qui changent la vieLibrairies Java qui changent la vie
Librairies Java qui changent la vie
 
Php seance1
Php seance1Php seance1
Php seance1
 
Nouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde MicrosoftNouveautés JavaScript dans le monde Microsoft
Nouveautés JavaScript dans le monde Microsoft
 
Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?
Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?
Les bi-thérapies à base de dérivés d'artémisinine: pourquoi et comment ?
 
Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011Grails from scratch to prod - MixIT 2011
Grails from scratch to prod - MixIT 2011
 

Plus de Jean Michel

Startup #7 : how to get customers
Startup #7 : how to get customersStartup #7 : how to get customers
Startup #7 : how to get customersJean Michel
 
HTML & CSS #10 : Bootstrap
HTML & CSS #10 : BootstrapHTML & CSS #10 : Bootstrap
HTML & CSS #10 : BootstrapJean Michel
 
Javascript #11: Space invader
Javascript #11: Space invaderJavascript #11: Space invader
Javascript #11: Space invaderJean Michel
 
Architecture logicielle #4 : mvc
Architecture logicielle #4 : mvcArchitecture logicielle #4 : mvc
Architecture logicielle #4 : mvcJean Michel
 
Architecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented designArchitecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented designJean Michel
 
Architecture logicielle #2 : TP timezone
Architecture logicielle #2 : TP timezoneArchitecture logicielle #2 : TP timezone
Architecture logicielle #2 : TP timezoneJean Michel
 
Architecture logicielle #1 : introduction
Architecture logicielle #1 : introductionArchitecture logicielle #1 : introduction
Architecture logicielle #1 : introductionJean Michel
 
PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles Jean Michel
 
Dev Web 101 #2 : development for dummies
Dev Web 101 #2 : development for dummiesDev Web 101 #2 : development for dummies
Dev Web 101 #2 : development for dummiesJean Michel
 
Startup #5 : pitch
Startup #5 : pitchStartup #5 : pitch
Startup #5 : pitchJean Michel
 
WebApp #1 : introduction
WebApp #1 : introductionWebApp #1 : introduction
WebApp #1 : introductionJean Michel
 

Plus de Jean Michel (15)

Startup #7 : how to get customers
Startup #7 : how to get customersStartup #7 : how to get customers
Startup #7 : how to get customers
 
HTML & CSS #10 : Bootstrap
HTML & CSS #10 : BootstrapHTML & CSS #10 : Bootstrap
HTML & CSS #10 : Bootstrap
 
Javascript #11: Space invader
Javascript #11: Space invaderJavascript #11: Space invader
Javascript #11: Space invader
 
Architecture logicielle #4 : mvc
Architecture logicielle #4 : mvcArchitecture logicielle #4 : mvc
Architecture logicielle #4 : mvc
 
Architecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented designArchitecture logicielle #3 : object oriented design
Architecture logicielle #3 : object oriented design
 
Architecture logicielle #2 : TP timezone
Architecture logicielle #2 : TP timezoneArchitecture logicielle #2 : TP timezone
Architecture logicielle #2 : TP timezone
 
Architecture logicielle #1 : introduction
Architecture logicielle #1 : introductionArchitecture logicielle #1 : introduction
Architecture logicielle #1 : introduction
 
PHP #6 : mysql
PHP #6 : mysqlPHP #6 : mysql
PHP #6 : mysql
 
PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles PHP #2 : variables, conditions & boucles
PHP #2 : variables, conditions & boucles
 
Dev Web 101 #2 : development for dummies
Dev Web 101 #2 : development for dummiesDev Web 101 #2 : development for dummies
Dev Web 101 #2 : development for dummies
 
Startup #5 : pitch
Startup #5 : pitchStartup #5 : pitch
Startup #5 : pitch
 
Projet timezone
Projet timezoneProjet timezone
Projet timezone
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Projet timezone
Projet timezoneProjet timezone
Projet timezone
 
WebApp #1 : introduction
WebApp #1 : introductionWebApp #1 : introduction
WebApp #1 : introduction
 

Javascript #2 : valeurs, types & opérateurs

  • 1. Javascript : Valeurs, types & opérateurs
  • 2. 1. Un programme javascript
  • 4. Moteurs JavaScript pour le développement Navigateur Console JSFiddle
  • 5. Les outils du développeur Javascript (1) FireFox Chrome Chrome Canary
  • 6. Les outils du développeur Javascript (2) Atom.io Sublime Text Brackets
  • 8. Un fichier javascript alert("Bazinga"); alert("Im not crazy."); alert("My mother had me tested");
  • 9. Quelques commandes alert("Suit up!"); console.log("Haaaaaave you met Ted?");
  • 10. Commentaires // Single Line Comments ! /* Multi-line Comments */
  • 11. 1.3 Où mettre du javascript ?
  • 12. JavaScript dans une page HTML (1) <!doctype html> <html> <head></head> <body> <script> alert('Hello world!'); </script> </body> </html>
  • 13. JavaScript dans une page HTML (2) <!doctype html> <html> <head></head> <body> <script src="hello.js"></script> </body> </html>
  • 16. Définir un nombre 890 // entier 87.90 // décimal 2.9e3 // 2.9 * 10 * 10 * 10
  • 17. Maximum & minimum (1) [-253 … 253]
  • 18. Maximum & minimum (2) 9007199254740992 + 1 == 9007199254740992; // true 0.2 + 0.4 == 0.6000000000000001; // true 1/7 + 1/7 + 1/7 + 1/7 + 1/7 + 1/7 + 1/7 != 1; // true
  • 19. Nombres spéciaux (1) Infinity // plus l'infini -Infinity // moins l'infini NaN // Not a Number
  • 20. Nombres spéciaux (2) Infinity + 1 == Infinity // true Infinity - Infinity == NaN // true 0/0 == NaN // true NaN + 1 == NaN // true
  • 21. 2.2 Chaînes de caractères
  • 22. Définir une chaîne de caractères "When I get sad I stop being sad and be AWESOME instead." 'True story!'
  • 23. Caractère d'échappement "There is only one god and his name is Death. And there is only one thing we say to Death: "Not today."" ! "A bear there was, a bear, a bear!n All black and brown, and covered with hair!n The bear! The bear!n Oh, come, they said, oh come to the fair!n The fair? Said he, but I'm a bear!n All black, and brown, and covered with hair!" ! "hodor hodor hodor"
  • 25. Booléens true != false // true true == 1; // true false == 0; // true
  • 26. Null & Undefined (1) Undefined : primitive value used when a variable has not been assigned a value Null : primitive value that represents the intentional absence of any object value
  • 27. Null & Undefined (2) undefined == null // true undefined != 0 // true null != 0 // true
  • 30. Arithmétique 3 + 2 == 5; 3 - 2 == 1; 3 * 2 == 6; 3 / 2 == 1.5; 3 % 2 == 1; ! 3 * 2 + 2 == 8;
  • 31. Concaténation "If you're committed enough, you can make any story work." + " I once told a woman I was Kevin Costner, and it worked because I believed it." + " - Saul Goodman »; ! // If you're committed enough, you can make any story work. I once told a woman I was Kevin Costner, and it worked because I believed it - Saul Goodman
  • 33. Numérique 3 > 2 // true 3 < 2 // false 8 == 9 // false 8 != 9 // true 9 >= 9 // true 9 <= 10 // true ! 9 == '9' // true 9 === '9' // false ! 'a' < 'u' // true; 'ab' < 'ba' // true 'a' < 'Z' // false
  • 34. Logique true && true // true true && false // false false && false // false ! true || true // true true || false // true false || false // false ! !true // false !false // true ! 3 + 4 == 7 && 2 * 8 > 10 // true
  • 35. Ternaire true ? 'yep' : 'nop' // yep false ? 'yeah' : 'noop' // noop
  • 36. 3.3 Types & transformations
  • 37. Types de données typeof 8 // number typeof 9.3 // number typeof NaN // number typeof 'toto' // string typeof true // boolean typeof null // object typeof undefined // undefined
  • 38. Conversion de type 3 * null // 0 "3" - 1 // 2 "3" + 1 // 4 "cinq" * 3 // NaN "five" * 3 // NaN false == 0 // true
  • 39. 4. Constantes & Variables
  • 40. Nommer une variable (1) Aucun espace Aucun mots clés réservés : break case catch continue debugger default delete do else false finally for function if implements in instanceof interface let new null package private protected public return static switch throw true try typeof var void while with yield this Aucune ponctuation sauf ‘_’ et ‘$’ Ne doit pas commencer par un chiffre
  • 41. Nommer une variable (2) // Syntax valide var a; var b, c; var s_variable; var b2; // Syntax invalide var 2a; var a:a; var function;
  • 42. Affecter une variable // Affecter une variable var a = 8, b = "toto", c = true, d; a = 2; console.log(a); // 2 console.log(b); // toto console.log(c); // true console.log(d); // undefined
  • 43. Constantes const a = 8; a = 2; console.log(a); // 8
  • 44. Merci pour votre attention.
  • 45. Bibliographie Eloquent JavaScript - Marijn Haverbeke http://eloquentjavascript.net Dynamisez vos sites web avec Javascript ! - Johann Pardanaud & Sébastien de la Marck http://fr.openclassrooms.com/informatique/cours/dynamisez-vos-sites-web-avec-javascript JavaScript Fundamentals - Jeremy McPeak http://code.tutsplus.com/courses/javascript-fundamentals Guide JavaScript - teoli, BenoitL, delislejm, Ame_Nomade, SphinxKnight https://developer.mozilla.org/fr/docs/Web/JavaScript/Guide Javascript – MAX_INT: Number Limits - Vjeux http://blog.vjeux.com/2010/javascript/javascript-max_int-number-limits.html
  • 46. Crédits (1) Lost - Jeffrey Lieber, J. J. Abrams, Damon Lindelof http://abc.go.com/shows/lost Person of interest - Jonathan Nolan, David Slack, Patrick Harbinson http://www.cbs.com/shows/person_of_interest/ Halt and Catch Fire - Christopher Cantwell, Christopher C. Rogers http://www.amctv.com/shows/halt-and-catch-fire Utilities terminal Icon - kxmylo http://www.iconarchive.com/show/simple-icons-by-kxmylo/utilities-terminal-icon.html Breaking bad - Vince Gilligan http://www.amctv.com/shows/breaking-bad House of Cards - Beau Willimon https://www.facebook.com/HouseofCards The Big Bang Theory - Chuck Lorre, Bill Prady http://www.cbs.com/shows/big_bang_theory/ Game of Thrones - David Benioff, D. B. Weiss http://www.hbo.com/game-of-thrones
  • 47. The Wire - David Simon http://www.hbo.com/the-wire Crédits (2) Silicon Valley - Mike Judge http://www.hbo.com/silicon-valley The Killing - Veena Sud http://www.amctv.com/shows/the-killing Band of Brothers - Tom Hanks, Steven Spielberg http://www.hbo.com/band-of-brothers