Table of contents
No headings in the article.
JavaScript has many built-in methods that provide useful functionality for working with data, strings, arrays, dates, and more. Here are some important built-in methods in JavaScript:
alert()
- displays a message in a dialog box.console.log()
- writes a message to the browser console.parseInt()
- converts a string to an integer.parseFloat()
- converts a string to a floating-point number.toString()
- converts a value to a string.toUpperCase()
- converts a string to uppercase.toLowerCase()
- converts a string to lowercase.concat()
- concatenates two or more strings.indexOf()
- returns the index of the first occurrence of a specified value in a string or array.lastIndexOf()
- returns the index of the last occurrence of a specified value in a string or array.slice()
- extracts a section of a string or array and returns it as a new string or array.splice()
- adds or removes elements from an array.sort()
- sorts the elements of an array.reverse()
- reverses the order of the elements in an array.join()
- joins all elements of an array into a string.push()
- adds an element to the end of an array.pop()
- removes the last element of an array.shift()
- removes the first element of an array.unshift()
- adds an element to the beginning of an array.toString()
- converts an array to a string.