API Reference

Array

.filter(callback) (see in MDN)

Executes a function on every element of the Array. It returns a new Array that contains only the elements for which the provided function returned true.

Example:

var myArray = [5, 6, 1, 2, 10];

var filteredArray = myArray.filter(function(num) {
    return num > 3; // Returns true only if the number is greater than 3
});

// filteredArray is [5, 6, 10]

.forEach(callback) (see in MDN)

Allows to execute a function on each and every element of the Array.

Example:

var myArray = ['Mickey', 'Goofy', 'Donald'];

myArray.forEach(function(name) {
   console.log('Hello' + name);
};

// Console Output
Hello Mickey
Hello Goofy
Hello Donald

.push(element) (see in MDN)

Appends an element at the end of the Array.

Example:

Event

.target (see in MDN)

Returns the element on which the event was captured.

.preventDefault() (see in MDN)

Cancels the default event behavior.

String

.replace(pattern, replacement) (see in MDN)

Returns a copy of the String with the given pattern replaced with another String.

Example:

.trim() (see in MDN)

Returns the original String without the whitespaces that it might have at the beginning or at the end.

Example:

JSON

.parse(jsonString) (see in MDN)

Converts a JSON string into a Javascript Object.

.stringify(object) (see in MDN)

Converts a Javascript Object into a JSON string.

document

.querySelector(cssSelector) (see in MDN)

Returns the first element that matches the provided CSS selector.

Example:

Element

.innerHTML (see in MDN)

Returns the HTML contained inside an Element. It can be set to a new value.

Example:

.previousElementSibling (see in MDN)

Returns the Element before the selected one.

Example:

.dataset (see in MDN)

Returns the map of the data- attributes of the selected element.

Example:

.value (see in MDN)

Returns or sets the value of the input field.

console

.log(text) (see in MDN)

Writes a message in the browser's console.

Last updated

Was this helpful?