Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

JS Methods

JS methods

Uploaded by

yhgosalg
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

JS Methods

JS methods

Uploaded by

yhgosalg
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Certainly!

Here's a brief definition of each category mentioned:

1. **Array Methods**: Methods for manipulating arrays. Examples include:

- `push()`: Adds one or more elements to the end of an array.

- `pop()`: Removes the last element from an array.

- `shift()`: Removes the first element from an array.

- `unshift()`: Adds one or more elements to the beginning of an array.

- `slice()`: Extracts a portion of an array.

- `splice()`: Changes the contents of an array by removing or replacing existing elements.

- `forEach()`: Executes a provided function once for each array element.

- `map()`: Creates a new array with the results of calling a provided function on every element.

- `filter()`: Creates a new array with elements that pass a certain condition.

- `reduce()`: Applies a function against an accumulator and each element in the array to reduce it to
a single value.

2. **String Methods**: Methods for manipulating strings. Examples include:

- `toUpperCase()`: Converts a string to uppercase.

- `toLowerCase()`: Converts a string to lowercase.

- `charAt()`: Returns the character at a specified index.

- `substring()`: Returns a subset of a string between two indices.

- `indexOf()`: Returns the index of the first occurrence of a specified value.

- `lastIndexOf()`: Returns the index of the last occurrence of a specified value.

- `concat()`: Combines two or more strings.

- `trim()`: Removes whitespace from both ends of a string.

- `split()`: Splits a string into an array of substrings.

3. **Object Methods**: Methods for working with objects. Examples include:

- `hasOwnProperty()`: Returns a boolean indicating whether an object has a specified property.

- `toString()`: Returns a string representation of an object.

- `valueOf()`: Returns the primitive value of an object.

- `isPrototypeOf()`: Checks if an object is in the prototype chain of another object.


- `propertyIsEnumerable()`: Returns a boolean indicating whether a specified property is
enumerable.

- `toLocaleString()`: Returns a string representing the object.

4. **Math Methods**: Static methods for mathematical operations. Examples include:

- `round()`: Rounds a number to the nearest integer.

- `floor()`: Rounds a number down to the nearest integer.

- `ceil()`: Rounds a number up to the nearest integer.

- `abs()`: Returns the absolute value of a number.

- `max()`: Returns the largest of zero or more numbers.

- `min()`: Returns the smallest of zero or more numbers.

- `random()`: Returns a pseudo-random number between 0 and 1.

5. **Date Methods**: Methods for working with dates. Examples include:

- `getDate()`: Returns the day of the month.

- `getMonth()`: Returns the month (0-11).

- `getFullYear()`: Returns the year.

- `getHours()`: Returns the hour (0-23).

- `getMinutes()`: Returns the minutes (0-59).

- `getSeconds()`: Returns the seconds (0-59).

- `getTime()`: Returns the numeric value corresponding to the time for the specified date.

6. **Global Functions**: Functions available globally. Examples include:

- `setTimeout()`: Calls a function or evaluates an expression after a specified number of


milliseconds.

- `setInterval()`: Calls a function or evaluates an expression at specified intervals.

- `clearTimeout()`: Clears a timeout previously set with `setTimeout()`.

- `clearInterval()`: Clears an interval previously set with `setInterval()`.

- `parseInt()`: Parses a string and returns an integer.

- `parseFloat()`: Parses a string and returns a floating-point number.

- `isNaN()`: Determines whether a value is NaN (Not a Number).

- `isFinite()`: Determines whether a value is a finite number.


- `encodeURI()`: Encodes a URI.

- `decodeURI()`: Decodes a URI.

- `encodeURIComponent()`: Encodes a URI component.

- `decodeURIComponent()`: Decodes a URI component.

7. **DOM Manipulation Methods**: Methods for interacting with the Document Object Model
(DOM). Examples include:

- `getElementById()`: Returns the element with the specified ID.

- `getElementsByClassName()`: Returns a collection of elements with the specified class name.

- `getElementsByTagName()`: Returns a collection of elements with the specified tag name.

- `querySelector()`: Returns the first element that matches a specified CSS selector.

- `querySelectorAll()`: Returns a NodeList containing all elements that match a specified CSS
selector.

- `createElement()`: Creates an HTML element.

- `appendChild()`: Appends a node as the last child of a node.

- `removeChild()`: Removes a child node from a parent node.

- `addEventListener()`: Attaches an event handler to an element.

- `removeEventListener()`: Removes an event handler from an element.

8. **Async/Await Methods**: Methods and keywords for handling asynchronous operations.


Examples include:

- `Promise`: A constructor for creating Promise objects.

- `async`: Declares an asynchronous function.

- `await`: Pauses the execution of an async function until the Promise is resolved or rejected.

- `then()`: Attaches callbacks for the resolution or rejection of a Promise.

- `catch()`: Attaches a callback for handling the rejection of a Promise.

- `finally()`: Attaches a callback that is executed when the Promise is settled, whether it's resolved
or rejected.

These are just brief descriptions, and each method or function has its own specific use cases and
details. The best way to understand them thoroughly is to refer to the official documentation or
experiment with them in your own code.

You might also like