-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
630f666
commit cd9d377
Showing
7 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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";` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |