Js entry-object attribute method summary

Source: Internet
Author: User
Tags base 10 logarithm natural logarithm
Today is the last section of the js getting started series demonstration (I plan it for the moment), but please remember, if you are familiar with the previous examples, it does not mean that we understand JS. Even when we get started, we have to admit that we are just standing on the threshold and haven't entered yet, then you may ask, why is it in a hurry? The answer is simple. Our ultimate goal is AJAX/Atlas. We will be exposed to a lot of JS things in subsequent tutorials, however, my lazy comments won't disappoint you, so we will continue to learn more about JS, next we must familiarize ourselves with the methods and attributes of JS's most important thing, object, because this is very important, and you can add this Post to your favorites, later. We do not deny that we are all genius, but we cannot deny that we are not a hard disk. Even if we are not a hard disk, there will be bad sectors on the hard disk. Who can remember?

 

Array: an ordered set of series elements;

For detailed demonstration, see: [js entry series demo-array] http://www.cnblogs.com/thcjp/archive/2006/08/04/467761.html

Attribute:

Length: used to obtain the number of array elements, that is, the maximum subscript plus 1

Method:

Sort (function): If no sorting number is specified, it is arranged alphabetically by the elements. If it is not a string type, it is converted to a string;

Reverse (): reverses the order of elements in the array;

Concat (array1, arrayn): Used to combine N numbers and add them to the array1 array;

Join (string): Used to merge the elements in the array into a string, and the string is the separator. If any parameter is omitted, the elements are directly merged without additional points;

Slice (start, stop): Used to return the elements from start to stop in the array. If the parameter is negative, it indicates the reciprocal start or stop element;

ToString (): returns a string of all elements in the array separated by commas;

String): No good explanation, see [javascript entry-js core language-string (string)] http://www.cnblogs.com/thcjp/archive/2006/08/11/474563.html

Attribute:

Length: returns the length of a string. It is used in the same way as an array;

Method:

Anchor (): This method creates a tag in the format of <a name = ""...> like the anchor in HTML, and accesses string. anchor (chorName) using the following methods)
For example, document. write ("to the day through. net \ ajax \ atlas blog view more tutorials" + myLink. link ("http://www.cnblogs.com/thcjp "))

ToUpperCase (): converts a string to uppercase;

ToLowerCase (): converts a string to lowercase;

IndexOf (a, B): searches for the position where character a appears in the string from character B and returns the result. If B is omitted, it searches from position 0 by default;

ChartAt (I): returns the I-th character in the string;

Substring (start, end): returns all characters in the string between start and end (but does not return the character of end itself );

Sub (): displays the specified string in subscript format;

Date: For details, see: Js entry-dynamic clock, display complete some of the methods, New Year countdown http://www.cnblogs.com/thcjp/archive/2006/08/16/478313.html

Definition method:

A: var newdt = new Date () --> Create a time object and assign a value to the current time;
B: var newdt = new Date (milliseconds) --> Create time object, and set the object Value in milliseconds Based on the delay time of GTM;
C: var newdt = new Date (string) --> assign values to the newly created time object using a specific time string. The format matches the parse method of the Date object;
D: var newdt = new Date (year, month, day, hour, minute, second, millisecond) --> by year, month, day, hour, minute, second, assign values to objects in milliseconds;

Method: minute acquisition time, set time, format conversion

A: Get time

GetDate () ----- get the current complete time;
GetYear () ------ get the current year
GetMonths () ---- get the current month
GetDay () ------- get the current date day
GetHours () ----- get the current hour
GetMinutes () --- get the current minute
GetSeconds () --- get the current second
GetTime () ------ get the current time, in seconds
GetTimeZoneOffset -- get the current time zone offset Information

B: set the time.

Replace get with set, for example, getDate () ---> setDate ()

C: Conversion Method

ToGTMString () ------ convert to the string of the Greenwich Mean Time expression;
ToLocaleString () ---- convert to a string expressed locally
ToString () ---------- convert time to string
Parse --------------- read the time from the string that represents the time
UTC ----------------- returns the gap from Greenwich Mean Time to the specified time, in milliseconds

Math mathematics: Demo example see javascript entry-javascript math object demo http://www.cnblogs.com/thcjp/archive/2006/08/12/475100.html

Attribute: note that attributes in a mathematical object refer to read attributes.

E (= 2.7182) ------ bottom of the natural logarithm (I don't understand what it means, alas, I don't understand anything close to mathematics, I'm depressed !)
LN10 (= 2.30259) --- the natural logarithm of 10;
LN2 (= 0.69315) ----- natural logarithm of 2;
PI (= 3.1415926) ---- circumference Rate
SQRT1_2 (= 0.7071) -- square root of 1/2
SQRT2 (= 1.4142) ---- the square root of 2
LOG2E (= 1.44269) --- base on 2, logarithm of E
LOG10E (= 0.43429) -- base 10 logarithm of E

Method: Actually, I don't have much to use. I'm depressed. Let's get it all out.

Sin (a) ---- returns the sine of.
Cos (a) ------ calculate the cosine of
Tan (a) ------ returns the tangent of
Asin (a) ----- returns the arc sine of.
Atan (a) ----- returns the arc cosine of.
Exp (a) ------ calculate the index of
Log (a) ------ calculate the natural logarithm of
Pow (a, I) ---- calculate the I power of a (multiplication)
Round (a) ---- rounding
Sqrt (a) ----- calculate the square root of
Abs (a) ------ calculate the absolute value of
Random () ---- random Number
Max (a, B) ---- take a large number
Min (a, B) ---- take a smaller number

Note: All function parameters are of the floating point type. The trigonometric function parameters are radians, rather than degrees.

JavaScript built-in functions

Demonstration see: [javascript entry-simple operations and data type conversion] http://www.cnblogs.com/thcjp/archive/2006/08/03/467150.html

Escape () and unescape (): encoding and decoding strings

Eval (string): used to execute operations or statements represented by strings
For example: var a = 0; var str1 = "a + = a"; eval (str1 );

ParseInt () and parseFloat (): Convert the value of the text box to an integer or floating point number.

Note: parseInt () is not used to round the number, but to cut the end.

IsNaN (): The complete E is (is not a number). As the name suggests, it is used to determine whether the string is a number, for example, if (isNaN ("tianbang series tutorial "))

Custom object:There are two methods: initialization object and Object Defining Constructor

For a detailed demonstration, see: javascript entry series demonstration-Function Definition and simple parameter use, call function http://www.cnblogs.com/thcjp/archive/2006/08/04/467487.html
[Js entry instance struct constructor \ method definition and call \ prototype object] http://www.cnblogs.com/thcjp/archive/2006/08/02/466100.html

A: initialization object

Example: object = {property 1: value 1; Property 2: Value 2 ;...... attribute n: value n}. Note that each attribute \ value pair is separated by a semicolon;

B: define the object of the constructor.

For example:
Function Name (attribute 1, attribute 2 ,... Attribute N ){

This. Attribute 1 = attribute value 1;
This. Attribute 2 = attribute value 2;
This. Attribute n = attribute value n;

This. method name 1 = function name 1;
This. method name 2 = function name 2;

}

Note: The method name and function name can have the same name. However, before calling a function, the function must be defined. Otherwise, an error occurs.

The new statement is used to create a new instance for a custom function.

Browser object

Window object: he belongs to the central level and is at the highest level of all objects. To put it bluntly, you can't play without him;

Demonstration see: js entry-mobile forms/pop-up prompt http://www.cnblogs.com/thcjp/archive/2006/08/03/466981.html
Examples of how to use javascript entry series demos in three pop-up dialog box http://www.cnblogs.com/thcjp/archive/2006/08/04/468047.html

Attributes: mainly include:

Closed ---------- used to determine whether the window is closed;
Opener ---------- store the open () method to open the parent window of the window;
Defaultstatus --- information displayed by default in the status bar;
Status ---------- information currently displayed in the status bar;
Document, Location, History --- very important. If you don't want to wait for it, read it here.

Method:

Alert (text) ------------- a prompt box is displayed.
Confirm (text) ----------- confirmation information box, the parameter is confirmation Information
Prompt (text, default) ---- the input dialog box is displayed. The parameters are the prompt information and default values.

Document Object: contains various features of the current webpage, such as the title, URL, background, language, and modification time.

See: javascript getting started-Document Object introduction (access forms, create new pages, get page titles) http://www.cnblogs.com/thcjp/archive/2006/08/08/470997.html
Js entry-open/close the window of the specified URL/change the link when the status bar text http://www.cnblogs.com/thcjp/archive/2006/08/04/468017.html

Attribute:

Title ------------ document title
LastModified ----- last modification time of the object
URL -------------- URL of the document
Cookie ----------- create and obtain Cookie Information
BgColor ---------- background color of the document
FgColor ---------- foreground color of the document
Location --------- save all the page address information of the document
Alinkcolor ------- activation connection color
Linkcolor -------- link color
Vlinkcolor ------- color of the browsed Link

Method:

Write (text) ----- write text or labels to the document without line breaks
Writeln (text) --- write text or tags to the document and wrap the line at the last character
Open () ---------- open a new document, such as open ("Address", "window name", "style ")
Close () --------- close the current document

Location object:Contains all the page addresses of the current document

Attribute:

Protocol ----------- communication protocol
Host --------------- host Name of the WEB server where the page is located
Port --------------- port number for server communication
Pathname ----------- path of the document on the server
Hash --------------- information about the page Jump anchor tag
Searce ------------- information submitted to the server for search
Hostname ----------- host name and port number, separated by a colon
Href --------------- complete URL

Method:

Assign (URL) -------- navigate the page to another address
Reload ------------- refresh the page
Replace (URL) ------- replace the current page with the specified URL

History: This object includes URL information previously accessed.

Attribute: length, number of returned URLs. The method is mainly go (n). This method is used to load the relative page.

It took me more than a day to summarize this article. If you want to repost it, please note the source of the name. I have worked very hard !!

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.