JavaScript Cheat Sheet
Properties |
|
constructor |
|
lenght |
|
prototype |
|
Methods & returned type |
|
String.fromCharCode(num1 [, ...[,numN]]) |
|
String.fromCodePoint(num1 [, ...[,numN]]) |
|
String.raw() |
|
str.charAt(index) |
new string |
str.charCodeAt(index) |
number |
str.codePointAt(position) |
number |
str.concat(string2[, string3, ..., stringN]) |
new string |
str.includes(searchTerm, position); |
boolean |
str.indexOf(searchValue, fromIndex) |
index |
str.lastIndexOf(searchValue[, fromIndex]) |
index |
str.search(regexp) |
string |
str.match(regexp) |
array |
str.matchAll(regexp) |
array |
str.padStart(targetLenght [, padString]) |
string |
str.padEnd(targetLengh t[, padString]) |
string |
str.repeat(count) |
string |
str.trim() |
string |
str.trimStart() |
string |
str.trimEnd() |
string |
str.replace(searchFor, replaceWith) |
new string |
str.replaceAll(searchFor, replaceWith) |
new string |
str.slice(beginIndex[, endIndex]) |
new string |
str.substring(indexStart[, indexEnd]) |
string |
str.split([separator[, limit]]) |
array |
str.startsWith(searchStr [, position]); |
boolean |
str.endsWith(searchStr[, position]); |
boolean |
str.toLowerCase() |
string |
str.toUpperCase() |
string |
str.toLocaleLowerCase() |
string |
str.toLocaleUpperCase() |
string |
str.valueOf() |
primitive |
str.localeCompare(strToCompare[,locales[, options]]) |
1 || 0 |
str.normalize([form]); |
string |
toString |
convertion |
boolean(0); |
false |
Boolean(-0) |
false |
(Boolean(null) |
false |
Boolean(false) |
false |
Boolean(NaN) |
false |
Boolean(undefined) |
false |
Boolean("") |
false |
Properties |
|
lenght |
|
constructor |
|
prototype |
|
Methods & returned value |
|
Array.from(arrayLike |
new array |
Array.isArray(value) |
boolean |
Array.of(item0[, item1[, ...[, itemN]]]) |
new array |
concat(value0, value1, ... , valueN) |
new array |
push(item0, item1, / ... ,/ itemN) |
number |
pop() |
string |
shift() |
number |
unshift(item0, item1, / ... ,/ itemN) |
number |
reverse() |
array |
slice(strat, end) |
array |
splice(start, deleteCount, item1, item2, itemN) |
array |
join(separator) |
string |
includes(searchElement, fromIndex) |
boolean |
find((element, index, array) => { ... } ) |
index |
findIndex((item, index, array) => { ... } ) |
index |
indexOf(searchElement, fromIndex) |
index |
lastIndexOf(searchElement, fromIndex) |
index |
copyWithin(target, start, end) |
array |
fill(value, start, end) |
array |
entries() |
new array |
keys() |
new array |
values() |
new array |
forEach(callback, thisArg) |
string |
map(callback [, thisArg]) |
new array |
filter(callback, thisArg); |
new array |
reduce(callbackFn, initialValue) |
value |
reduceRight(callbackFn, initialValue) |
value |
some(callback[, objetThis]) |
boolean |
every(callback[, thisArg]) |
boolean |
sort(fonctionComparaison) |
object |
flat(depth) |
new array |
flatMap(function) |
new array |
toString() |
string |
Opérateurs logiques |
&& AND, || OR, ! NOT |
Opérateurs de comparaison |
==, ===, =!, ==!, >, >, =, <, <= |
Opérateurs arithmétiques |
+, -, , /, %, * |
Opérateurs d'affectation |
+=, -=, =, /=, %=, * |
Incrémentation Décrémentation |
i++, ++i, i--, --i |
Opérateur ternaire |
condition ? val1(true) : val2(false); |
Opérateurs unaires |
delete, typeof, void, +, -, ~, ! |
Opérateurs relationnels |
in, instanceof |
Properties |
|
Number.MIN_VALUE |
Number.MAX_VALUE |
Number.MIN_SAFE_INTERGER |
Number.MAX_SAFE_INTERGER |
Number.NaN |
EPSILON |
NEGATIVE_INFINITY |
POSITIVE_INFINITY |
Methods & returned type |
|
Number.isNaN() |
boolean |
Number.isFinite() |
boolean |
Number.isInteger() |
boolean |
Number.isSafeInteger() |
boolean |
Number.parseFloat(string) |
number |
Number.parseInt(string, [base]) |
number |
toExponential(fractionDigits) |
string |
toFixed(digits) |
number |
toPrecision(precision) |
string |
toString([radix]) |
string |
valueOf() |
number |
Math.round() |
Arrondi à l'entier le plus proche |
Math.floor() |
Arrondi à l'entier inférieur |
Math.ceil() |
Arrondi à l'entier supérieur |
Math.min() |
Renvoie le plus petit nombre |
Math.max() |
Renvoie le plus grand nombre |
Math.sign() |
Renvoie le signe d'un nombre |
Math.abs() |
Renvoie le valeur absolue |
Math.sqrt() |
Renvoie le racine carrée |
Math.pow(x, y) |
Renvoie le puissance |
Math.log |
Renvoie le logarithme |
Math.random |
Renvoie un nombre aléatoire |
Pattern Modifiers |
|
i insensible à la case |
g match global |
m multiligne matching |
|
Brackets |
|
[abc] ou [a-c] |
Correspond à n'importe quels caractères entre les crochets |
[abc] ou [a-c] |
Correspond à tout ce qui n'est pas indiqué entre les crochets. |
[a-ZA-Z-0-9_] |
Tout caractères qui n'est pas une lettre ou un chiffre |
[0-9] |
|
[A-z] |
|
(a|b|c) |
|
x|y |
Correspond à 'x' ou 'y' |
Character classes |
|
\w word |
\W NOT word |
\d digit |
\D NOT digit |
\s whitespace |
\S NOT whitespace |
\t tabs |
\n line breaks |
Quantifiers |
|
z? 0 ou 1 occurrence |
z 0 ou multiple occurrences* |
z+ 1 ou multiple occurrences |
z{n} n occurrences |
z{min,max} min/max occurrences |
|
Anchors |
|
^hello start of the strings |
|
hello$ end of the string |
|
\b limite de mot |
\B pas limite de mot |
x(?=y) 'x' s'il est suivi de 'y' |
|
x(?|y|) 'x' s'il n'est pas suivi de 'y' |
|
(?<=y)x 'x' s'il est précédé par 'y' |
|
(?<!y)x x' s'il n'est pas précédé par 'y' |
|
String regexp function |
|
match() search() replace() split() |
|
regexp methods |
|
test() exec() |
|
if ... else |
if (condition) { |
switch |
switch (expression) { |
while |
while (condition){ |
do ... while |
do { |
for |
for ([Initiale]; [condition]; [Incrémt]) { |
label |
label : |
break [label] |
for (i = 0; i < a.length; i++) { |
continue [ label ]; |
while (i < 5) { |
for ... in |
for (variable in objet) { |
for ... of |
for (variable of objet) { |
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.