Javascript Cheatsheet 2026
Javascript Cheatsheet 2026
COM
BASIC FUNDAMENTAL DATATYPES
&
&
CALLBACK FOR EACH METHODS n .size return number of items o .pop() remove & return last element
/ .forEach( (e,i,a) ) exec for each METHODS n .push( o1 , o2 ...) adds to end
m .set( key , value ) add pair (k,v) wm o .shift() remove & return last element
F Function o .get( key ) get value of key wm n .unshift( o1 , o2 ...) inserts at start
PROPERTIES b .has( key ) check key existence wm
o .length get number of arguments b .delete( key ) remove element wm n number d date
s .name return name of arguments / .clear() remove all items
/ Not a number s
- - string
o .prototype prototype object ITERATION METHODS
METHODS i .keys() list keys i .values() list values
r regular expr f function
o .call( newthis , a1 ...) set this i .entries() list pair (key, value) b boolean o object
o .apply( newthis , a1 ...) ↳ array CALLBACK FOR EACH METHODS a array / undefined
o .bind( newthis , a1 ...) ↳ no run / .forEach( (e,i,a) ) exec for each ? static method ? instance method
LENGUAJEJS
MATH REGEXP OBJECTS
,,
.COM
&
&
D Date legacy
( ) T Temporal
METHODS TYPES TD Temporal Duration
n .UTC( y , m , d , h , i , s , ms ) o .PlainTime hh:mm:ss TYPES
n .now() timestamp of current time o .PlainYearMonth yyyy-mm o .Duration P_Y_M_W_DT_H_M_S
n .parse( str ) convert str to timestamp o .PlainMonthDay mm-dd METHODS
n .setTime( ts ) set UNIX timestamp o .PlainDate yyyy-mm-dd o .from( date | opt ) create date obj
n .getTime() return UNIX timestamp o .PlainDateTime yyyy-mm-ddThh:nn:ss n .compare( date1 , date2 ) (-1,0,1)
UNIT GETTERS SETTERS GETUTC
/ . */.SETUTC* o .ZonedDateTime yyyy-mm-ddThh:nn:ss[z] DURATION PROPERTIES
n .get/.setFullYear( y , m , d ) (yyyy) METHODS b .blank duration is zero ?
n .get/.setMonth( m , d ) (0-11) o .from( date | opt ) create date object n .years get year (defined)
n .get/.setDate( d ) (1-31) n .compare( date1 , date2 ) (-1,0,1) n .months get months (defined)
n .get/.setHours( h , m , s , ms ) (0-23) CALC METHODS n .weeks get weeks (defined)
n .get/.setMinutes( m , s , ms ) (0-59) o .add( date | opt ) add duration to date n .days get days (defined)
n .get/.setSeconds( s , ms ) (0-59) o .subtract( date | opt ) sub dur. to date n .hours get hours (defined)
n .get/.setMilliseconds( ms ) (0-999) o .since( date | opt ) difference from date n .minutes get minutes (defined)
n .getDay() return day of week (0-6) o .until( date | opt ) difference to date n .seconds get seconds (defined)
n .getTimezoneOffset() mins (-840-840) b .equals( date | opt ) check equality n .milliseconds get millisecs
LOCALE TIMEZONE METHODS
& o .round( date | opt ) truncate date n .microseconds get microsecs
s .toLocaleDateString( locale , options ) MODIFY METHODS n .nanoseconds get nanosecs
s .toLocaleTimeString( locale , options ) o .with( d | opt ) set fields n .sign sign of duration (-1,0,1)
s .toLocaleString( locale , options ) o .withCalendar( d | opt ) set calendar DURATION METHODS
s .toUTCString() return UTC date o .withPlainTime( d | opt ) set time o .abs() get positive duration
s .toDateString() return American date o .withTimeZone( d | opt ) set timezone o .negated() invert duration (negate)
s .toTimeString() return American time CONVERT METHODS o .round( unit | opt ) truncate to unit
s .toISOString() return ISO8601 date o .toInstant() → get Instant date o .add( duration ) duration + duration
s .toJSON() return date ready for JSON o .toJSON() → serialize (ISO) o .subtract( duration ) dur1 - dur2
o .toLocaleString() → get local format o .toJSON() get JSON-format duration
Units o .toPlainDate() → PlainDate o .toLocaleString() human duration
UNITS o .toPlainDateTime() → PlainDateTime o .total( unit | opt ) calc in unit
n .year 2025 n .hour 13 o .toPlainTime() → PlainTime o .with( units ) modify units
n .month 6 n .hoursInDay 24 o .toPlainMonthDay() → PlainMonthDay
n .day 7 n .minute 30 o .toPlainYearMonth() → PlainYearMonth TI Temporal Instant
n .dayOfWeek 6 n .second 0 o .toZonedDateTime() → ZonedDateTime TYPES
n .dayOfYear 158 n .millisecond 0 TIMEZONE METHODS o .Instant yyyy-mm-ddThh:nn:ssZ
n .daysInMonth 30 n .microsecond 0 o .getTimeZoneTransition( dir | opt ) PROPERTIES
n .daysInYear 365 n .nanosecond 0 o .startOfDay( date | opt ) beginning day n .epochMilliseconds get timestamp
OTHER UNITS b .epochNanoseconds get timestamp
s .calendarId "iso8601" T Temporal Now METHODS
s .monthCode "M06" TYPES o .add( date | opt ) add duration
n .yearOfWeek 2025 o .Now get current date/time o .subtract( date | opt ) sub duration
n .monthsInYear 12 METHODS o .since( date | opt ) diff from date
n .weekOfYear 23 o .instant() → get Instant date o .until( date | opt ) diff to date
n .daysInWeek 7 o .plainDateISO() → PlainDate b .equals( date | opt ) check equality
s .era "bce" o .plainDateTimeISO() → PlainDateTime o .round( date | opt ) trunc date
n .eraYear 2022 o .plainTimeISO() → PlainTime CONVERT METHODS
b .inLeapYear false o .zonedDateTimeISO() → ZonedDateTime o .toJSON() → serialize (ISO)
TIMESTAMP PROPERTIES s .timeZoneId() get current timezone o .toLocaleString() get local format
n .epochMilliseconds 1766261720000 o .toZonedDateTime() ZonedDateTime
b .epochNanoseconds 17662617200...0n Temporal examples
TIMEZONE PROPERTIES TEMPORAL EXAMPLES CONVERT DATE TO TEMPORAL
s .timeZoneId "Europe/London" [Link]() 2026-12-20 const d = new Date(); legacy date
s .offset "+01:00" [Link]( "2026-12-20" ) [Link] date → Temporal
n .offsetNanoseconds 0 [Link]( "P2D" ) 2026-12-22 .fromEpochMilliseconds( d )
LENGUAJEJS ,,
.COM
PROMISES FETCH ESM MODULES &
&
P Promise F Fetch
STATIC METHODS METHODS
p .all( list ) wait all resolve [ ] p fetch( url | request , opt ) HTTP request XMLHttpRequest
p .allSettled( list ) wait all finish (resolve/reject) [ ] p fetchLater( url | request , opt ) deferred HTTP request
p .any( list ) wait first resolve [ 1 ✓ ]
p .race( list ) wait first finish (resolve or reject) [ ✓ ] R Request Response /
E SN O P SER
p .resolve( value ) create direct resolved promise ✓ b .redirected url is redirected
p .reject( value ) create direct rejected promise ✖ n .status HTTP code error
INSTANCE METHODS s .statusText status related for code error
p .then( resolve , reject ) handle result (success) or rejected (error) s .type basic, cors, default, error...
p .then( resolve ) runs when promise is fullfilled (success) o .body content (string, FormData, Blob...)
p .catch( reject ) runs when promise is rejected (error) b .bodyUsed .body has been used
p .finally( end ) always run when finish (resolved or rejected) o .headers http header Headers or Object
ASYNC AWAIT
/
s .url absolute full http url
async function name() { ... } prepare function return promise ONLY REQUEST PROPERTIES
const data = await name() wait promise, block execution s .cache → default, reload, no-cache, no-store...
s .credentials → omit, same-origin, include
M Modules Import Export
( / ) s .destination content type → json, script, iframe...
.duplex enable request body streaming: half
TS E U Q E R
MODULES SPECIFIER s
import ... from "./file. js" ; load from relative file URL s .integrity hash integrity value (ej: sha256-...)
import ... from "name" ; bare import (node_modules/, maps...) b .isHistoryNavigation request is a history navigation
import ... from "@/name/file. js" ; alias import (vite, typescript...) b .isReloadNavigation request is a reload/refresh
import ... from "node:package" ; import built-in node package b .keepalive browser will keep request alive
s .method request HTTP method: GET, POST, HEAD...
import ... from "h ps://[Link]/file. js" ; load from absolute URL
s .mode → cors, no-cors, same-origin, navigate...
STATIC IMPORTS PRE RUNNING TIME
.redirect mode → follow, error, manual.
-
s
MAIN IMPORTS
s .referrer previous url of user navigation
import { name } from "./file. js" ; import data from module
s .referrerPolicy → no-referrer, strict-origin...
import { name as rename } from "./file. js" ; ↳ and rename
o .signal set AbortSignal to abort request
import { m1 , m2 , ... } from "./file. js" ; ↳ multiple data
METHODS
import * as name from "./file. js" ; ↳ import all in object p .arrayBuffer() → binary data as buffer (raw data)
import "./file. js" ; no import data, only run external code p .blob() → raw file-like object (store images, files...)
DEFAULT IMPORT .bytes() → return raw bytes (low-level byte handle)
TS E U Q E R
p
import name from "./file. js" ; import default data with name p .clone() → duplicate response object (reuse)
DYNAMIC IMPORT RUNNING TIME .formData() → parse form data (handle html form)
E SN O P SER
p
p import( "./file. js" ) dynamic import file (running time) p .json() → parse JSON content (json to object)
STATIC EXPORTS p .text() → return as text (plain text string)
export { m1 , m2 , ... } export multiple data (node-style) STATIC METHODS
export ... export element (prefix, direct-style) o .error() create error response (failed network requests)
export default ... export data as default import of module o .json( data , opt ) return json response (send json data)
IMPORT META o .redirect( url , code ) redirect to URL (http redirection)
s [Link] get absolute URL of module
s [Link]( name ) resolve bare import to full URL A AbortController
PROPERTIES
R Resource Modules o .signal AbortSignal object
STATIC IMPORT METHODS
import name from "./fi[Link]" with { type: "json" } parse json / .abort( reason ) abort async operation
import styles from "./fi[Link]" with { type: "css" } parse css ABORTCONTROLLER EXAMPLE
DYNAMIC IMPORTS const controller = new AbortController(); create abort
p import( "./file. json" , { with: { type: "json" }}) ↳ parse json fetch("...", { signal : controller .signal }) assign signal
p import( "./fi[Link]" , { with: { type: "css" }}) ↳ parse css [Link](); send signal to abort async operation
LENGUAJEJS
DOCUMENT DOM EVENTS
.COM
,, &
&
d document Properties
( ) s SanitizerConfig A Attr
PARSE STATIC METHODS a .elements allowed elements PROPERTIES
o .parseHTML( html , opt ) strict parse PARAMETERS s .name name of element attribute
o .parseHTMLUnsafe( html , opt ) soft parse a .elements allowed elements s .value value of element attribute
PROPERTIES a .attributes allowed attributes
s .title document title a .removeElements removed elements DTL DOM Token List
o .doctype document type header a .removeAttributes removed attributes PROPERTIES
s .characterSet doc charset .charset a .replaceWithChildrenElements unwrap n .length number of items
s .compatMode quirks or standard mode ENABLE FEATURES s .value all items concatenated
s .cookie all cookies document b .comments allow comments METHODS
s .currentScript current run script / null b .dataAttributes allow data-* b .contains( name ) item exist?
s .documentURI full URL .URL / .add( name ,...) add item to list
s .referrer previous user page d document Methods
( ) s .item( n ) get item number n
s .dir text direction METHODS / .remove( name ) delete item
s .lastModified date/time modification SEARCH FROM POINT b .toggle( name ) conmute item
LOADING STATE o .caretPositionFromPoint( x , y ) node b .replace( old , now ) replace item
b .prerendering prerender loading state e .elementFromPoint( x , y ) first element b .supports( name ) item support?
s .readyState ready state a .elementsFromPoint( x , y ) all elements / .forEach( (e,i,a) ) create iterator
API STATES s .evaluate( xpath , doc ) XPath search ITERATORS
s .visibilityState page visibility .hidden API METHODS i .keys() get names of tokens
b .fullscreenEnabled fullscreen API p .exitFullscreen() close fullscreen API i .values() get values of tokens
b .pictureInPictureEnabled PiP API p .exitPictureInPicture() close PiP API i .entries() get pair name-values
STYLES AND FONTS / .exitPointerLock() unlock pointer
o .fonts Font Loading API b .hasFocus() page is focused? S Selection
o .styleSheets style sheets ANIMATIONS PROPERTIES
a .adoptedStyleSheets adopted styles a .getAnimations() list css animations s .type selection type
ELEMENTS p .startViewTransition() animate pages s .direction selection dir
o .defaultView default view: window SEARCH DOM n .rangeCount range count
e .getElementById( id ) search first element b .isCollapsed
e .documentElement refer <html> element
a .getElementsByClassName( class ) class NODES
e .body refer <body> element
a .getElementsByName( name ) name e .baseNode base node
e .head refer <head> element
a .getElementsByTagName( tag ) <tag> NS e .anchorNode start node
e .scrollingElement current scrolling tag
e .querySelector( css ) first element e .extentNode end node
e .activeElement current focus html tag
a .querySelectorAll( css ) all elements e .focusNode focus node
FF FontFace o .getSelection() get text selection data OFFSETS
PROPERTIES STORAGE ACCESS METHODS n .baseOffset base offset
p .hasStorageAccess() n .anchorOffset start offset
n .size number of @fontface rules
p .hasUnpartitionedCookieAccess() n .extentOffset end offset
s .status loading or loaded
p .requestStorageAccess() n .focusOffset focus offset
p .ready all fonts loaded
CREATION METHODS
METHODS
e .createAttribute( name ) → Attr NS
R Range
o .add( font ) add a new font PROPERTIES
b .check( cssrule , limit ) check render font e .createDocumentFragment() → Fragment
e .createElement( tag , opt ) → Tag NS b .collapsed collapsed range
/ .clear() remove all fonts added with JS NODES
b .delete( font ) o .createRange() → Range
e .createTextNode( text ) → Text e .commonAncestorContainer
b .has( cssrule ) exist font? e .startContainer start node
p .load( cssrule , limit ) force load font e .createComment( text ) → Comment
s .adoptNode( node ) move node to outside e .endContainer end node
/ .forEach( (e,i,a) ) loop fonts OFFSETS
ITERATORS s .importNode( node , deep ) clone node
s .append( node ,...) .writeln() n .startOffset start offset
i .values() iterate fonts n .endOffset end offset
i .entries() iterate entries s .prepend( node ,...) .write()
E Element Properties
( ) E Element Methods
( )
DR DOMRect
PROPERTIES METHODS
PROPERTIES
s .accessKey set accessKey attribute o .animate( keyframes , time | opt )
n .x .left horizontal start position
m .attributes get attribute/value list a .getAnimations() all anims of element
n .y .top vertical start position
s .className value of class attribute b .checkVisibility() element is visible?
n .width rectangle width
o .classList classes control helper m .computedStyleMap() get computed styles
n .height rectangle height
s .id get id attribute value o .attachShadow( options ) Create Shadow DOM
n .bottom vertical end position
s .name get name attribute value b .matches( css ) check if match with css selector
n .right horizontal end position
s .tagName get uppercase tag name DOM RECT METHODS
s .localName get lowercase tag name o .getBoundingClientRect() Element DOMRect y/top ↓
s .namespaceURI namespace tag a .getClientRects() DOMRect list
←width→
s .prefix namespace prefix (xml) ATTRIBUTE METHODS x/left → right →
↕ height ↕
o .part css part control helper b .hasAttribute( name ) check if exist attrib NS
DOM HIERARCHY b .hasAttributes() check if has at least 1 attribute bottom ↓
n .childElementCount child number a .getAttributeNames() get list of attributes
a .children child element list s .getAttribute( name ) get attribute value NS N Nodes
e .firstElementChild first child / .setAttribute( name , value ) set attrib value NS PROPERTIES
e .lastElementChild last child o .getAttributeNode( name ) get Attr node NS s .baseURI document base URL
e .previousElementSibling prev tag o .setAttributeNode( a r ) set Attr node NS s .nodeName tag uppercase name
e .nextElementSibling next tag b .toggleAttribute( name , force ) add/del attrib n .nodeType node kind
SHADOW DOM / .removeAttribute( name ) delete attribute NS a .childNodes all children
o .shadowRoot get shadow DOM SCROLL METHODS o .firstChild first child node
s .slot get name slot / .scrollBy( x , y ) / .scrollBy( opt ) relative o .lastChild last child node
e .assignedSlot get <slot> / .scrollTo( x , y ) / .scrollTo( opt ) absolute o .previousSibling prev node
ELEMENT SIZE POS
/ ELEMENT SCROLL / .scrollIntoView( top | opt ) visual scroll o .nextSibling next node
s .clientWidth s .scrollWidth / .scrollIntoViewIfNeeded( center ) ↳ conditional o .ownerDocument document root
s .clientHeight s .scrollHeight SEARCH CHILD ELEMENTS e .parentElement parent tag
s .clientTop s .scrollTop a .getElementsByClassName( class ) find by class e .parentNode parent node
s .clientLeft s .scrollLeft a .getElementsByTagName( tag ) find by tag NS b .isConnected inserted in DOM?
s .currentCSSZoom css zoom value e .querySelector( css ) first tag match by css s .textContent node text value
HTML PROPERTIES a .querySelectorAll( css ) all tags match by css METHODS
s .innerHTML get/set html code SEARCH PARENT ELEMENTS e .cloneNode( deep ) clone tree
s .outerHTML ↳ with wrapper tag e .closest( css ) first ancestor match by css e .getRootNode( opt ) root parent
MODERN HTML METHODS .INNERHTML ELEMENT API b .contains( node ) check node
s .getHTML( opt ) get html code / .after( node ,...) insert node after element b .hasChildNodes() has children
/ .setHTML( html , opt ) safe html / .append( node ,...) insert node as child at end b .isEqualNode( node ) content
/ .setHTMLUnsafe( html , opt ) / .before( node ,...) insert node before element b .isSameNode( node ) node
/ .prepend( node ,...) insert node as child at start s .lookupNamespaceURI( prefix )
SO Shadow Options / .remove() remove element from document s .lookupPrefix( namespace )
PROPERTIES REPLACE CHILD ELEMENT API
/ / .normalize() merge text nodes
s .mode "open" or "closed" / .replaceChildren( node ,...) replace child NODE API
b .clonable with .cloneNode() / .replaceWith( node ,...) replace node element e .appendChild( node ) add node
b .delegatesFocus focus inside / .moveBefore( child , target ) → before target e .removeChild( node ) del node
b .serializable included in export ADJACENT API e .replaceChild( new , old )
s .slotAssignment how slot match / .insertAdjacentHTML( pos , html ) insert html e .insertBefore( new , ref )
/ .insertAdjacentElement( pos , el ) insert elem
SD Shadow DOM / .insertAdjacentText( pos , text ) insert textnode P Position
SHADOW DOM CREATION API METHODS PROPERTIES
const options = { mode: "open" } / .setPointerCapture( id ) capture all event s "beforebegin" [ ]
[Link]( options ); b .hasPointerCapture( id ) element captured? s "afterbegin" [ ]
ELEMENTS / .releasePointerCapture( id ) release capture s "beforeend" [ ]
element main DOM (hidden) p .requestPointerLock( opt ) infinite mouse moves s "afterend" [ ]
[Link] shadow DOM p .requestFullscreen( opt ) enable fullscreen
LENGUAJEJS ,,
.COM
LANGUAGE TIMERS URL GLOBALS ,, &
&
ESUOM
b .once only one-time event false mouseenter o .Collator( code , opt ) string comparator
b .passive never call .preventDefault() false mouseleave o .DisplayNames( code , opt ) locale names
o .signal set AbortSignal to remove listener mouseleave o .PluralRules( code , opt ) plural categories
RETNIOP ESUOM
mouseover o .Segmenter( code , opt ) text segmentation
E Event CustomEvent
/ mouseout o .Locale( code , opt ) locale identifier object
PROPERTIES contextmenu METHODS
/
b .composed can pass through shadow dom false pointerenter a .formatToParts( n ) ↳ to array
b .defaultPrevented action already prevented false pointerleave RANGE METHODS ONLY NUMBER DATETIME &
o .detail additional event info, only CustomEvent pointerover s .formatRange( start , end ) range
n .eventPhase current event stage (0-3) pointerout a .formatRangeToParts( start , end ) ↳ split
b .isTrusted user action or dispatched false pointercancel COLLATOR METHODS
o .currentTarget active listener element null wheel n .compare( str1 , str2 ) compares two strings
RCS
a .composedPath() element list (propagation path) keypress s .select( n ) get plural name
/ .preventDefault() cancel default event action copy s .selectRange( start , end ) get plural ranges
/ .stopImmediatePropagation() stop all listeners cut SEGMENTER METHODS
/
/ .stopPropagation() stop event bubbling paste o .segment( str ) locale segments string
o .when( name , opt ) create ev. stream Observable touchstart LOCALES METHODS
H C U OT
o focusin reset
o .take( n ) process only first n o .first() focusout input s .key( n ) get key name on position n
o .takeUntil( expr ) process to n o .last() change submit s .getItem( key ) get value of key key
o .drop( n ) ignore first n items a .toArray() animationstart / .setItem( key , value ) set value
o .switchMap( func ) switch to new stream animationend / .removeItem( key ) remove key
SN O I TA M I NA
o .inspect( (expr) ) peek values/debug animationiteration / .clear() remove all items (current site)
ERRORS METHODS transitionstart
o .catch( f ) handle errors o .finally( f ) cleanup transitionend G GeneratorFunction
transitionrun EXAMPLE { VALUE : ..., DONE FALSE
: }