If you want to learn about JavaScript, refer

Source: Internet
Author: User

StringObject. charAt (index) method: returns the character at the specified index position.
StringObject. slice (start, [end]) and stringObject. the substring (start, [end]) method accepts two parameters, namely the start position and end position of the sub-string, respectively. A string between the two is returned, excluding the string at the end position. If the second parameter is not specified, the default value is the length of the string, from the starting position to the end of the string.
[Difference] the difference between the two methods is that the processing of negative numbers is different. The negative number parameter is counted forward from the end of the string for slice (), while the substring () directly ignores the negative number and treats it as 0, and uses 0 as the start position, A positive number is used as the termination position. For example, substring (2,-3) is equivalent to substring)
StringObject. substr (start, [length]) method: returns a string starting from the subscript start with length.
StringObject. indexOf (searchStr, [fromIndex]) method: returns the index number of the string searchStr that appears in the stringObject string for the first time from fromIndex. -1 is returned if Str is not included in stringObject. (Search from past to future)
StringObject. lastIndexOf (searchStr, [fromIndex]) method: returns the index number that appears in the stringObject string for the first time from the string searchStr (calculated from the end. -1 is returned if Str is not included in stringObject. (Search from the back)
The parseInt (string, [radix]) function parses a string and returns an integer. Radix indicates the number to be converted to a number (Optional). The default value is decimal.
The parseFloat (string) function parses a string and returns a floating point number.
Array declaration in JavaScript:
New Array ();
New Array (size );
New Array (element0, element0,..., elementn );
[Element0, element0,..., elementn];
The arrayObject. join ([separator]) method returns a string. This string is generated by converting each element of the arrayObject into a string, connecting these strings, and inserting the separator string between the two elements.
The stringObject. split (separator, [howator]) method returns an array created by splitting the stringObject string into substrings at the boundary specified by separator. How indicates the maximum length of the returned array (optional ). StringObject. split ("") can split the stringObject string into letters.
The arrayObject. reverse () method is used to reverse the order of elements in the array. No return value.
The arrayObject. sort () method is used to sort array elements. No return value.
JavaScript-defined functions
Function functionName ([arg0, arg1 ,..., ArgN])
{
Statements
[Return [expression]
}
Parameters used to access the function using the arguments object. For example, arguments [0] can access the value of the first parameter.
The Math. random () method returns a value ranging from 0 ~ A random number between 1.
BOM (Brower Object Model) browser Object Model
Including window, document, location, navigator, and screen
Common Properties and methods of Window objects include:
Window. moveBy (dx, dy): Move the browser window horizontally to the right of the current position dx pixels, vertically down dy pixels;
Window. moveTo (x, y): Move the browser window to (x, y) of the user's screen;
Window. resizeBy (dw, dh): In contrast to the current size of the browser window, increase the width by dw pixels and the height by dy pixels;
Window. resizeTo (w, h): Adjust the width of the browser window to w pixels and the height to h pixels;
Window. open ([newWindowURL], [newWindowName], [feature1, feature2…]) : Open a new window. NewWindowName is equivalent to the target attribute of the <a> tag.
WindowObject. opener: access the original window of windowObject;
Window. close (): close the current window;
Window. status = "…" : Set the text in the status bar;
Window. alert ("…") : A prompt is displayed;
Window. confirm ("…") : A confirmation box is displayed;
Window. prompt ([text], [defaultText]): a prompt box is displayed. defaultText is the default text (optional );
Window. history. go (-1)/window. history. back (): return a page;
Window. history. go (1)/window. history. forward (): the first page.
The documentobject is a Windows Object, which can be accessed through the upload Doc ument attribute.
Common method: document. write ("…")
The Location object is an attribute of the Window object and can be accessed through the window. location attribute.
Common attributes: location. href = URL
Navigator object
Common attributes: navigator. userAgent (usually the browser determines whether to use this attribute .)
The Screen Object is also an attribute of the Window object.
Common attributes:
Screen. availHeight: the screen height that can be used by the window;
Screen. availWidth: the screen width that can be used by the window;
Screen. colorDepth: the number of digits in the color;
Screen. height: screen height;
Screen. width: the screen width.

Related Article

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.