search
HomeWeb Front-endFront-end Q&AWhat are javascript built-in functions?

What are javascript built-in functions?

Feb 16, 2022 pm 05:49 PM
javascriptbuilt-in functions

In JavaScript, built-in functions refer to functions that come with the browser kernel and can be used directly without introducing any function library. Common built-in functions can be divided into five categories: 1. Regular functions; 2. Array functions; 3. Date functions; 4. Mathematical functions; 5. String functions.

What are javascript built-in functions?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Built-in functions in javascript

js built-in functions come with the browser kernel and can be used directly without introducing any function library function.

Common built-in functions can be divided into five categories:

1, regular function

2, array function

3, Date function

4, math function

5, string function

The first category: regular function

includes the following 9 Functions:

(1) alert function: displays a warning dialog box, including an OK button.

(2)confirm function: Display a confirmation dialog box, including OK and Cancel buttons.

(3)escape function: Convert characters into Unicode codes.

(4)eval function: calculates the result of an expression.

(5)isNaN function: Test whether (true) or not (false) is not a number.

(6)parseFloat function: Convert a string into dotted digital form.

(7)parseInt function: Convert the string into integer digital form (the decimal system can be specified).

(8)prompt function: Display an input dialog box, prompting to wait for user input.

Second Category: Array Function

Includes the following 4 functions:

(1)Join function: Convert and join all elements in the array is a string.

(2)langth function: Returns the length of the array.

(3)reverse function: Reverse the order of array elements.

(4)sort function: Reorder array elements.

The third category: date function

Includes the following 20 functions:

(1)getDate function: returns the "day" part of the date, The value is 1~31

(2)getDay function: returns the day of the week, the value is 0~6, where 0 means Sunday, 1 means Monday,..., 6 means Saturday

(3 )getHours function: Returns the "hour" part of the date, the value is 0~23.

(4)getMinutes function: Returns the "minutes" part of the date, the value is 0~59. See the example above.

(5)getMonth function: Returns the "month" part of the date, the value is 0~11. Among them, 0 represents January, 2 represents March, ..., and 11 represents December. See previous example.

(6)getSeconds function: Returns the "seconds" part of the date, the value is 0~59. See previous example.

(7)getTime function: Returns the system time.

(8)getTimezoneOffset function: Returns the time difference in this region (the regional time difference between local time and GMT Greenwich Mean Time), in minutes.

(9)getYear function: Returns the "year" part of the date. The return value is based on 1900, for example, 1999 is 99.

(10)parse function: Returns the number of milliseconds since 0:00 on January 1, 1970 (local time).

(11)setDate function: Set the "day" part of the date, the value is 0~31.

(12)setHours function: Set the "hour" part of the date, the value is 0~23.

(13)setMinutes function: Set the "minutes" part of the date, the value is 0~59.

(14)setMonth function: Set the "month" part of the date, the value is 0~11. Among them, 0 represents January, ..., and 11 represents December.

(15)setSeconds function: Set the "seconds" part of the date, the value is 0~59.

(16)setTime function: set time. The time value is the number of milliseconds since 00:00 on January 1, 1970.

(17)setYear function: Set the "year" part of the date.

(18)toGMTString function: Convert the date into a string, which is GMT Greenwich Mean Time.

(19)setLocaleString function: Convert date into string and local time.

(20) UTC function: Returns the number of milliseconds since 0:00 on January 1, 1970, calculated in GMT Greenwich Mean Time.

var myDate=new Date(dtime.replace(/-|\./g,"/"));
myDate.getYear();        //获取当前年份(2位)
myDate.getFullYear();    //获取完整的年份(4位,1970-????)
myDate.getMonth();       //获取当前月份(0-11,0代表1月)
myDate.getDate();        //获取当前日(1-31)
myDate.getDay();         //获取当前星期X(0-6,0代表星期天)
myDate.getTime();        //获取当前时间(从1970.1.1开始的毫秒数)
myDate.getHours();       //获取当前小时数(0-23)
myDate.getMinutes();     //获取当前分钟数(0-59)
myDate.getSeconds();     //获取当前秒数(0-59)
myDate.getMilliseconds();    //获取当前毫秒数(0-999)
myDate.toLocaleDateString();     //获取当前日期
var mytime=myDate.toLocaleTimeString();     //获取当前时间
myDate.toLocaleString( );        //获取日期与时间

setTimeout();
setInterval();

Fourth Category: Mathematical Functions

The functions have the following 18:

(1)abs function: Math.abs (the same below) ), returns the absolute value of a number.

(2) acos function: Returns the inverse cosine value of a number, and the result is 0 to π radians (radians).

(3)asin function: Returns the arcsine value of a number, and the result is -π/2~π/2 radians.

(4)atan function: Returns the arctangent value of a number, and the result is -π/2~π/2 radians.

(5)atan2 function: Returns the polar coordinate angle value of a coordinate.

(6)ceil function: Returns the smallest integer value of a number (greater than or equal to).

(7)cos function: Returns the cosine value of a number, and the result is -1~1.

(8)exp function: Returns the power value of e (natural logarithm).

(9)floor function: Returns the maximum integer value of a number (less than or equal to).

(10)log function: natural logarithm function, returns the natural logarithm (e) value of a number.

(11)max function: Returns the maximum value of two numbers.

(12)min function: Returns the minimum value of two numbers.

(13)pow function: Returns the power of a number.

(14)random function: Returns a random value between 0 and 1.

(15)round function: Returns the rounded value of a number, the type is integer.

(16)sin function: Returns the sine value of a number, and the result is -1~1.

(17)sqrt function: Returns the square root value of a number.

(18)tan function: Returns the tangent value of a number.

Fifth Category: String Function

Includes the following 20 functions:

(1)anchor function: generates a link point (anchor) Used as a hyperlink. The anchor function sets the name of the link point of , and the other function link sets the URL address of .

(2)big function: Increase the font size to one, which is the same as the ... tag.

(3)blink function: Makes the string blink, which is the same as the ... tag result.

(4)bold function: Make the font bold, which is the same as the ... tag result.

(5)charAt function: Returns a character specified in the string.

(6)fixed function: Set the font to a fixed-width font, which is the same as the ... tag.

(7)fontcolor function: Set the font color, which is the same as the tag result.

(8)fontsize function: Set the font size, which is the same as the tag result.

(9)indexOf function: Returns the first index found in the string, starting from the left.

(10) italics function: Make the font italic, which is the same as the ... tag result.

(11)lastIndexOf function: Returns the first subscript index found in the string, starting from the right.

(12)length function: Returns the length of the string. (Without parentheses)

(13) link function: Generate a hyperlink, which is equivalent to setting the URL address of .

(14)small function: Reduce the font size by one size, which is the same as the ... tag.

(15)strike function: Add a horizontal line in the middle of the text, which is the same as the ... tag.

(16)sub function: Display the string as a subscript.

(17)substring function: Returns several characters specified in the string.

(18)sup function: Display the string as superscript.

(19)toLowerCase function: Convert the string to lowercase.

(20)toUpperCase function: Convert the string to uppercase.

[Related recommendations: javascript learning tutorial]

The above is the detailed content of What are javascript built-in functions?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML and React's Integration: A Practical GuideHTML and React's Integration: A Practical GuideApr 21, 2025 am 12:16 AM

HTML and React can be seamlessly integrated through JSX to build an efficient user interface. 1) Embed HTML elements using JSX, 2) Optimize rendering performance using virtual DOM, 3) Manage and render HTML structures through componentization. This integration method is not only intuitive, but also improves application performance.

React and HTML: Rendering Data and Handling EventsReact and HTML: Rendering Data and Handling EventsApr 20, 2025 am 12:21 AM

React efficiently renders data through state and props, and handles user events through the synthesis event system. 1) Use useState to manage state, such as the counter example. 2) Event processing is implemented by adding functions in JSX, such as button clicks. 3) The key attribute is required to render the list, such as the TodoList component. 4) For form processing, useState and e.preventDefault(), such as Form components.

The Backend Connection: How React Interacts with ServersThe Backend Connection: How React Interacts with ServersApr 20, 2025 am 12:19 AM

React interacts with the server through HTTP requests to obtain, send, update and delete data. 1) User operation triggers events, 2) Initiate HTTP requests, 3) Process server responses, 4) Update component status and re-render.

React: Focusing on the User Interface (Frontend)React: Focusing on the User Interface (Frontend)Apr 20, 2025 am 12:18 AM

React is a JavaScript library for building user interfaces that improves efficiency through component development and virtual DOM. 1. Components and JSX: Use JSX syntax to define components to enhance code intuitiveness and quality. 2. Virtual DOM and Rendering: Optimize rendering performance through virtual DOM and diff algorithms. 3. State management and Hooks: Hooks such as useState and useEffect simplify state management and side effects handling. 4. Example of usage: From basic forms to advanced global state management, use the ContextAPI. 5. Common errors and debugging: Avoid improper state management and component update problems, and use ReactDevTools to debug. 6. Performance optimization and optimality

React's Role: Frontend or Backend? Clarifying the DistinctionReact's Role: Frontend or Backend? Clarifying the DistinctionApr 20, 2025 am 12:15 AM

Reactisafrontendlibrary,focusedonbuildinguserinterfaces.ItmanagesUIstateandupdatesefficientlyusingavirtualDOM,andinteractswithbackendservicesviaAPIsfordatahandling,butdoesnotprocessorstoredataitself.

React in the HTML: Building Interactive User InterfacesReact in the HTML: Building Interactive User InterfacesApr 20, 2025 am 12:05 AM

React can be embedded in HTML to enhance or completely rewrite traditional HTML pages. 1) The basic steps to using React include adding a root div in HTML and rendering the React component via ReactDOM.render(). 2) More advanced applications include using useState to manage state and implement complex UI interactions such as counters and to-do lists. 3) Optimization and best practices include code segmentation, lazy loading and using React.memo and useMemo to improve performance. Through these methods, developers can leverage the power of React to build dynamic and responsive user interfaces.

React: The Foundation for Modern Frontend DevelopmentReact: The Foundation for Modern Frontend DevelopmentApr 19, 2025 am 12:23 AM

React is a JavaScript library for building modern front-end applications. 1. It uses componentized and virtual DOM to optimize performance. 2. Components use JSX to define, state and attributes to manage data. 3. Hooks simplify life cycle management. 4. Use ContextAPI to manage global status. 5. Common errors require debugging status updates and life cycles. 6. Optimization techniques include Memoization, code splitting and virtual scrolling.

The Future of React: Trends and Innovations in Web DevelopmentThe Future of React: Trends and Innovations in Web DevelopmentApr 19, 2025 am 12:22 AM

React's future will focus on the ultimate in component development, performance optimization and deep integration with other technology stacks. 1) React will further simplify the creation and management of components and promote the ultimate in component development. 2) Performance optimization will become the focus, especially in large applications. 3) React will be deeply integrated with technologies such as GraphQL and TypeScript to improve the development experience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.