JS basic functions and Basic methods

Source: Internet
Author: User

Date-time functions (which need to be called with variables):

var B = new Date (); Get current time

B.gettime ()//Get timestamp

B.getfullyear ()//Get Year

B.getmonth (+1); Get month

B.getdate ()//Get Day

B.gethours ()//Get Hours

B.getminutes ()//Get minutes

B.getseconds ()//Get the number of seconds

B.getday ()//Get the day of the week

B.getmilliseconds ()//Get milliseconds

Date ()//Get full date

Mathematical functions (called with math):

ABS (x) The absolute value of the return number.

Ceil (x) is rounded on the logarithm.

Floor (x) is rounded down with a logarithmic.

Round (x) rounds the number to the nearest integer.

Max (x, y) returns the highest value in X and Y.

Min (x, y) returns the lowest value in X and Y.

The POW (x, y) returns the y power of X.

SQRT (x) returns the square root of the number.

Random () returns an arbitrary number between 0 and 1. ****

String functions (called with variables):

IndexOf

Returns the index (from left to right) of the first occurrence of a substring in a string. If there is no match, returns-1.

CharAt

Returns the character at the specified position.

LastIndexOf

Returns the index (right-to-left search) at the last occurrence of a substring in a string, or 1 if there are no matches

Match

Checks if a string matches the contents of a regular expression, and returns null if there is a match.

Substring

Returns a substring of a string in which the incoming parameter is the starting and ending position

Substr

Returns a substring of a string in which the incoming parameter is the starting position and length

Replace *******

Replace String, the first argument represents the replaced string, the second argument represents the replacement string

Search

Performs a regular expression matching lookup. If the lookup succeeds, returns the matching index value in the string. otherwise returns-1.

Split ******

A string is made into a string array by dividing the string into substrings.

Length property *******

Returns the length of a string, the length of which is the number of characters it contains

toLowerCase

Turns the entire string into lowercase letters.

toUpperCase

Turns the entire string into uppercase.

JS basic functions and Basic methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.