Home >Web Front-end >Front-end Q&A >What are javascript built-in functions?

What are javascript built-in functions?

青灯夜游
青灯夜游Original
2022-02-16 17:49:373923browse

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 c15da42579d2d9c6ecf2a46a5b849f87, and the other function link sets the URL address of 6a2b3936541eb5c40626a82687b7bf27.

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

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

(4)bold function: Make the font bold, which is the same as the 9368c5823948a595f9974a5e2b3bd3f1...41908b66e4bc50a75b443e0dfafd01f9 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 93d6511c7669df5bfbcd3880050b7aa3...4b3fc97737cbf18af15f2ba7bc5d77cd tag.

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

(8)fontsize function: Set the font size, which is the same as the b199633d0149a1f3cd04d7545e597261 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 7a282450d175f90c7a1cab18e4a7ad13...a7d43287c9e69e794166deeac33b9b9c 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 6a2b3936541eb5c40626a82687b7bf27.

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

(15)strike function: Add a horizontal line in the middle of the text, which is the same as the 57cd6b64c8b9044cd4fad141699574a0...d5a0e3f5d79f9603e2d1a28898a2f705 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