CHEAT SHEET
JAVASCRIPT WEB DEVELOPMENT
Created by @Manz ( https://twitter.com/Manz ) https://lenguajejs.com/
n Number() = 42 s String() = 'text' a Array() = [1, 2, 3]
PROPERTIES PROPERTIES PROPERTIES
n .POSITIVE_INFINITY +∞ equivalent n .length string size n .length number of elements
n .NEGATIVE_INFINITY -∞ equivalent METHODS METHODS
n .MAX_VALUE largest positive value s .charAt(index) char at position [i] b .isArray(obj) check if obj is array
n .MIN_VALUE smallest positive value n .charCodeAt(index) unicode at pos. b .includes(obj, from) include element?
n .EPSILON diff between 1 & smallest >1 n .codePointAt(index) cp at position n .indexOf(obj, from) find elem. index
n .NaN not-a-number value s .fromCharCode(n1, n2...) code to char n .lastIndexOf(obj, from) find from end
METHODS s .fromCodePoint(n1, n2...) cp to char s .join(sep) join elements w/separator
s .toExponential(dec) exp. notation s .concat(str1, str2...) combine text + a .slice(ini, end) return array portion
s .toFixed(dec) fixed-point notation b .startsWith(str, size) check beginning a .concat(obj1, obj2...) return joined array
s .toPrecision(p) change precision a .flat(depth) return flat array at n depth
b .endsWith(str, size) check ending
b .isFinite(n) check if number is finite b .includes(str, from) include substring?
MODIFY SOURCE ARRAY METHODS
b .isInteger(n) check if number is int. a .copyWithin(pos, ini, end) copy elems
n .indexOf(str, from) find substr index
b .isNaN(n) check if number is NaN a .fill(obj, ini, end) fill array with obj
n .lastIndexOf(str, from) find from end
n .parseInt(s, radix) string to integer n a .reverse() reverse array & return it
.search(regex) search & return index
n .parseFloat(s, radix) string to float a .sort(cf(a,b)) sort array (unicode sort)
n .localeCompare(str, locale, options)
a .splice(ini, del, o1, o2...) del&add elem
a .match(regex) matches against string
r Regexp() ITERATION METHODS
= /.+/ig a .matchAll(regex) return iterator w/all
ai .entries() iterate key/value pair array
PROPERTIES s .normalize(form) unicode normalize
n .lastIndex index to start global regexp s ai .keys() iterate only keys array
.padEnd(len, pad) add end padding
s .flags active flags of current regexp s ai .values() iterate only values array
.padStart(len, pad) add start padding
b .global flag g (search all matches) s .repeat(n) repeat string n times CALLBACK FOR EACH METHODS
b .ignoreCase flag i (match lower/upper) s .replace(str|regex, newstr|func) b .every(cb(e,i,a), arg) test until false
b .multiline flag m (match multiple lines) s .slice(ini, end) str between ini/end b .some(cb(e,i,a), arg) test until true
b .sticky flag y (search from lastIndex) s a .map(cb(e,i,a), arg) make array
.substr(ini, len) substr of len length
b .unicode flag u (enable unicode feat.) a .filter(cb(e,i,a), arg) make array w/true
s .substring(ini, end) substr fragment
s .source current regexp (w/o slashs) o
a .split(sep|regex, limit) divide string .find(cb(e,i,a), arg) return elem w/true
METHODS
s .toLowerCase() string to lowercase n .findIndex(cb(e,i,a), arg) return index
a .exec(str) exec search for a match
s .toUpperCase() string to uppercase a .flatMap(cb(e,i,a), arg) map + flat(1)
b .test(str) check if regexp match w/str
s .trim() remove space from begin/end .forEach(cb(e,i,a), arg) exec for each
CLASSES
s .trimEnd() remove space from end o .reduce(cb(p,e,i,a), arg) accumulative
. any character \t tabulator o .reduceRight(cb(p,e,i,a), arg) from end
s .trimStart() remove space from begin
\d digit [0-9] \r carriage return
\D no digit [^0-9] \n line feed s .raw`` template strings with ${vars} ADD/REMOVE METHODS
\w any alphanumeric char [A-Za-z0-9_] o .pop() remove & return last element
d Date()
\W no alphanumeric char [^A-Za-z0-9_] n .push(o1, o2...) add elem & return length
METHODS
\s any space char (space, tab, enter...) o .shift() remove & return first element
\S no space char (space, tab, enter...) n .UTC(y, m, d, h, i, s, ms) timestamp n .unshift(o1, o2...) add elem & return len
\xN char with code N [\b] backspace n .now() timestamp of current time
\uN char with unicode N \0 NUL char n .parse(str) convert str to timestamp UNSHIFT
[1,2,3]
PUSH
CHARACTER SETS OR ALTERNATION n .setTime(ts) set UNIX timestamp SHIFT POP
[abc] match any character set n .getTime() return UNIX timestamp f Function() = function(a, b) { ... }
[^abc] match any char. set not enclosed UNIT GETTERS / SETTERS (ALSO .getUTC*() / .setUTC*() )
PROPERTIES
a|b match a or b n .get / .setFullYear(y, m, d) (yyyy) o .length return number of arguments
BOUNDARIES n .get / .setMonth(m, d) (0-11) s .name return name of function
^ begin of input $ end of input n .get / .setDate(d) (1-31) o .prototype prototype object
\b zero-width word boundary n .get / .setHours(h, m, s, ms) (0-23) METHODS
\B zero-width non-word boundary n .get / .setMinutes(m, s, ms) (0-59) o .call(newthis, arg1, arg2...) change this
GROUPING n .get / .setSeconds(s, ms) (0-59) o .apply(newthis, arg1) with args array
(x) capture group (?:x) no capture group n .get / .setMilliseconds(ms) (0-999) o .bind(newthis, arg1, arg2...) bound func
\n reference to group n captured n .getDay() return day of week (0-6)
QUANTIFIERS LOCALE & TIMEZONE METHODS
n number d date
x* preceding x 0 or more times {0,} n .getTimezoneOffset() offset in mins n NaN (not-a-number) r regular expresion
x+ preceding x 1 or more times {1,} s .toLocaleDateString(locale, options) s string f function
x? preceding x 0 or 1 times {0,1} s .toLocaleTimeString(locale, options) b boolean (true/false) o object
x{n} n ocurrences of x s .toLocaleString(locale, options) a array undefined
x{n,} at least n ocurrences of x s .toUTCString() return UTC date available on ECMAScript 2015 or higher
x{n,m} between n & m ocurrences of x s .toDateString() return American date n static (ex: Math.random())
ASSERTIONS s .toTimeString() return American time n non-static (ex: new Date().getDate())
x(?=y) x (only if x is followed by y) s .toISOString() return ISO8601 date
argument required
x(?!y) x (only if x is not followed by y) s .toJSON() return date ready for JSON
argument optional