Show Menu

Javascript Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.



event delegation




prototypal inheri­tance

Math Class

Math.m­ax(­[va­lue1[, value2[, ...]]])


The apply() method calls a function with a given this value, and arguments provided as an array (or an array-like object).
var max = Math.m­ax.a­pp­ly(­null, numbers);


arr.i­nd­exO­f(­se­arc­hEl­ement[, fromIn­dex­])
The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.
The find() method returns the value of the first element in the array that satisfies the provided testing function. Otherwise undefined is returned.
var found =­nd(­fun­cti­on(­ele­ment) { return element > 10; });
The map() method creates a new array with the results of calling a provided function on every element in the calling array.
const map1 = => x * 2);


An object is a collection of proper­ties, and a property is an associ­ation between a name (or key) and a value. A property's value can be a function, in which case the property is known as a method. In addition to objects that are predefined in the browser, you can define your own objects.
A JavaScript object has properties associated with it. A property of an object can be explained as a variable that is attached to the object. Object properties are basically the same as ordinary JavaScript variables, except for the attachment to objects. The properties of an object define the charac­ter­istics of the object. You access the properties of an object with a simple dot-no­tation:
var myCar = new Object(); myCar.make = 'Ford'; myCar.m­odel = 'Mustang'; myCar.year = 1969;
Unassigned properties of an object are undefined (and not null).
myCar.c­olor; // undefined
Properties of JavaScript objects can also be accessed or set using a bracket notation (for more details see property access­ors). Objects are sometimes called associ­ative arrays, since each property is associated with a string value that can be used to access it. So, for example, you could access the properties of the myCar object as follows:
myCar[­'make'] = 'Ford'; myCar[­'mo­del'] = 'Mustang'; myCar[­'year'] = 1969;
Property accessors provide access to an object's properties by using the dot notation or the bracket notatio
person = {'firs­tname': 'John', 'lastn­ame': 'Doe'}
person['firstname'] = 'Mario'; person­['l­ast­name'] = 'Rossi';
myOthe­rMe­tho­d(p­arams) { // something else }
Nearly all objects in JavaScript are instances of Object; a typical object inherits properties (including methods) from­oto­type, although these properties may be shadowed (a.k.a. overri­dden). However, an Object may be delibe­rately created for which this is not true (e.g. by­eat­e(n­ull)), or it may be altered so that this is no longer true (e.g. with­tPr­oto­typ­eOf).


These are code structures which listen for things happening in browser, running code in response.
Attach event to an element
docume­nt.q­ue­ryS­ele­cto­r('­htm­l').on­click = function() {};
var myHTML = docume­nt.q­ue­ryS­ele­cto­r('­html'); myHTML.on­click = function() {};

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi