Basic JavaScript knowledge 2

Source: Internet
Author: User

One Variable

Use the VaR keyword inside the function body to define local variables.

Binary Value

Math. Round (), math. Floor (), and math. Ceil ()

Math. Random ()

Math. Abs ()

Tofixed ()

Parseint () and parsefloat ()

Three strings

You can use single or double quotation marks. If the quotation marks in a string are necessary, escape them.

Available methods and Properties of string objects

Length, indexof () and lastindexof (), charat (), substring (), split (), tolowercase (), touppercase ()

Four-Structure Control

If, elseif, switch (switch must have the same data type, similar to =)

For, while, do while, break and continue

Try catch finally

Five functions

Functions can also be passed as variables.

Vi. Object

 

7. event registration

1 inline Event Handlers <a href = "somewhere.html" onclick = "highlightnavitem ()">

2 The traditional model

<A href = "somewhere.html" id = "somewhere">

VaR x = Document. getelementbyid ('somewhere ');

X. onclick = highlightnavitem; // Note: No parentheses

3 executing Event Handlers directly

X [I]. onkeyup = x [I]. onchange = checkmaxlength;

X [I]. onkeyup ();

 

4 anonymous Functions

5 W3C and Microsoft Models

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.