JS Third Class

Source: Internet
Author: User

Javascript (iii)

1. Functions

function functionname (arg1,arg2 ...)

{

.....

}

Return statement usage

2. Objects

Properties/Methods

var avalues=new Array ();

var mystring=new String ("Hello World");

3. Date Object (var mydate=new date ())

1) Calculate program execution speed (get milliseconds) 1.html

2) method

Method

Describe

getFullYear ()

Returns a four-digit year

GetMonth ()

Returns the month (current month-1)

GetDate ()

Return date (starting from 1)

GetDay ()

Return day of the week (Sunday 0)

GetHours ()

Returns the number of hours (starting from 1)

Getminutes ()

Returns the number of minutes (starting from 1)

Getseconds ()

Returns the number of seconds (starting at 1)

Getmilliseconds ()

Returns the number of milliseconds (starting at 0)

GetTime ()

Returns the number of milliseconds elapsed from GMT time January 1, 1970 0:0 0 seconds

Get current time: 2.html

Get difference days: 3.html

4. Math Object

1) Properties

Math.ln10

Natural logarithm of 10

Math.ln2

Natural logarithm of 2

math.log2e

Logarithm of base E of 2

math.log10e

Logarithm of base E of 10

Math.PI

Pi

Math.sqrt1_2

Square root of 1/2

Math.sqrt2

Square root of 2

2) method

Maximum value: Math.max (18,12,22,33)

Minimum value: Math.min (18,2,2,3,1)

Round up: Math.ceil (25.9)//It rounds the number up to the nearest integer

Rounding Down: Math.floor (25.6)

Rounding: Math.Round (25.6)

Random number between 0~1: Math.random ()//excluding 0 and 1

var Inum=math.floor (Math.random () *100+1)//Returns an integer between 1~100 including 1 and 100

Other methods

5. Window Object

1) window.open ("http://www.baidu.com", "_blank", "height=300,width=400,top=30,left=140,resizable=yes");

Resizable Whether you can resize a new window by dragging the default is Yes

Scrollable whether the new window shows scroll bars default to No

2) Close the new window

Window.close ()

3) alert (), confirm (), prompt ()

Confirm ("OK delete?") ")//Return Boolean type

4) Window.history.go (-1)//browser back one page

Window.history.go//forward one page

You can also use:

Window.history.back ()

Window.history.forward ()

JS Third Class

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.