JavaScript has a wide range of built-in functions that can be used for various purposes. Here is a list of JavaScript functions:

  • alert() – displays an alert box with a message
  • console.log() – writes a message to the browser’s console
  • prompt() – displays a dialog box for the user to input a value
  • parseInt() – converts a string to an integer
  • parseFloat() – converts a string to a floating-point number
  • isNaN() – checks if a value is not a number
  • String() – converts a value to a string
  • Number() – converts a value to a number
  • Boolean() – converts a value to a boolean
  • typeof() – returns the type of a value
  • Math.random() – returns a random number between 0 and 1
  • Math.floor() – rounds a number down to the nearest integer
  • Math.ceil() – rounds a number up to the nearest integer
  • Math.round() – rounds a number to the nearest integer
  • Math.max() – returns the largest of zero or more numbers
  • Math.min() – returns the smallest of zero or more numbers
  • Math.abs() – returns the absolute value of a number
  • Math.sqrt() – returns the square root of a number
  • Date() – returns the current date and time
  • setTimeout() – sets a timer to execute a function after a specified time
  • setInterval() – sets a timer to execute a function repeatedly after a specified time
  • clearTimeout() – cancels a timeout set with setTimeout()
  • clearInterval() – cancels an interval set with setInterval()
  • encodeURI() – encodes a URI
  • decodeURI() – decodes a URI

This list is not exhaustive, JavaScript has many more built-in functions and also you can create your own functions as well.

Some Additional JavaScript Functions

Here are some additional JavaScript functions that are commonly used:

  • Array.prototype.push() – adds an element to the end of an array
  • Array.prototype.pop() – removes the last element from an array
  • Array.prototype.shift() – removes the first element from an array
  • Array.prototype.unshift() – adds an element to the beginning of an array
  • Array.prototype.slice() – returns a new array with a subset of the elements of an array
  • Array.prototype.splice() – adds or removes elements from an array
  • Array.prototype.sort() – sorts the elements of an array
  • Array.prototype.filter() – creates a new array with all elements that pass a certain test
  • Array.prototype.map() – creates a new array with the results of calling a provided function on every element in the array
  • Array.prototype.forEach() – calls a function once for each element in an array
  • Array.prototype.reduce() – applies a function against an accumulator and each element in the array to reduce it to a single value
  • Array.prototype.concat() – returns a new array that concatenates two or more arrays
  • Array.prototype.indexOf() – returns the first index at which a given element can be found in the array, or -1 if it is not present
  • Array.prototype.lastIndexOf() – returns the last index at which a given element can be found in the array, or -1 if it is not present
  • String.prototype.length – returns the length of a string
  • String.prototype.concat() – concatenates two or more strings
  • String.prototype.toUpperCase() – converts a string to uppercase
  • String.prototype.toLowerCase() – converts a string to lowercase
  • String.prototype.substring() – returns a subset of a string
  • String.prototype.split() – splits a string into an array of substrings
  • String.prototype.replace() – replaces a substring with another string
  • String.prototype.search() – searches for a substring in a string and returns its position
  • String.prototype.match() – searches for a match between a regular expression and a string
  • String.prototype.trim() – removes whitespace from the beginning and end of a string
  • JSON.stringify() – converts a JavaScript object to a JSON string
  • JSON.parse() – converts a JSON string to a JavaScript object
  • Object.keys() – returns an array of the keys of an object
  • Object.values() – returns an array of the values of an object
  • Object.entries() – returns an array of the key-value pairs of an object
  • Object.assign() – copies the values of all enumerable own properties from one or more source objects to a target object

Also Read:

Categorized in: