Skip to content

Commit

Permalink
JS values as prez slides
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBruant committed Feb 16, 2016
1 parent 630f666 commit cd9d377
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 0 deletions.
5 changes: 5 additions & 0 deletions slides/04-javascript/04-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Variables

* TOUJOURS déclarer avec `var`
* Toujours utiliser le [mode strict](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Functions_and_function_scope/Strict_mode/Transitioning_to_strict_mode)
* `"use strict";`
19 changes: 19 additions & 0 deletions slides/04-javascript/05-valeurs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Valeurs

* number
* string
* boolean (`true`, `false`)
* null
* undefined
* object (`Object(x) === x`)
* function (`typeof f === 'function'`)
* Array (`Array.isArray(x)`)
* Date
* RegExp
* symbols (ES2015)

notes:


null & undefined
(/!\ `typeof null === "object"`, comparer `maVariable === null`)
18 changes: 18 additions & 0 deletions slides/04-javascript/06-comparaison.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Comparaison

* TOUJOURS utiliser `===` et `!==`
* `==` "presque égal"
* `===` "strictement égal"
* Comparaison par référence pour les objets, par valeur pour le reste.

````js
console.log(1 === 1)
console.log('yo' === 'yo')

var o = { a: 1 };
var o2 = o;
console.log(o === o2);

var o3 = { a: 1 };
console.log(o !== o3);
````
18 changes: 18 additions & 0 deletions slides/04-javascript/07-string.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Strings

* '', 'yo', 'whatever'
* '' ou "" indifféremment
* 'doesn\'t' et "doesn't"

````js
'Yo'.toUpperCase()
'Yo'.toLowerCase()
'Yo'.slice(start, end)
'Yo'.substring(start, end)
'Yo'.substr(start, length)
'yyyyyyy'.replace('y', 'a') // /!\ only the first occurence
'yyyyyyy'.replace(/y/g, 'a')
str.trim()
str.match()
str.length
````
14 changes: 14 additions & 0 deletions slides/04-javascript/08-number.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Number

* Un seul type de nombre, pas de distinction int/float/double
* 1, 23, 1.6, Math.PI
* signe*mantisse*2^exp

````js
// NaN, Infinity
console.log( NaN !== NaN )
Number.isNaN(x) // /!\ NE PAS utiliser isNaN !!
toto.toFixed(2)
Math.PI.toFixed(3)
Math.PI.toString()
````
9 changes: 9 additions & 0 deletions slides/04-javascript/09-math.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Math

````js
Math.random();
Math.pow(x, e);
Math.sqrt(x);
Math.hypot(a, b, c); // (ES2015) Math.sqrt( a*a + b*b + c*c )
Math.round(21.1); // floor, ceil
````
16 changes: 16 additions & 0 deletions slides/04-javascript/10-boolean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Booleans

````js
!!maValeur
console.log( 67 && 37 && null && 'kjhg' )
console.log( 0 || 37 || null )
````

## "Falsy values"

* false
* 0
* NaN
* '' // chaîne vide
* null
* undefined

0 comments on commit cd9d377

Please sign in to comment.