Basic Introduction to JavaScript knowledge

Source: Internet
Author: User

ECMAScript

JS Simple Introduction (the difference from Java)
1. Syntax (case sensitive, weak type, semicolon writable, not writable)
2. Variable (can only use the var definition, or not defined, if you use the var definition inside the function, then it is a local variable, if not using Var, it is a global variable)
3. Data type (undefined defined no assignment/null variable does not exist/string/number/boolean)
4. Statement: with keyword

var smessage = "Hello";        With (smessage) {          alert (touppercase ());    Output "HELLO"        }


5. Operator: = = and = = = Difference (= = is the same, data type can be different, = = = is strictly the same, if different is false)
if ("==120") Alert ("Equal")
if ("===120") alert ("Exactly equal")
The first print is equal, the second one does not print
6. Functions: 2 Ways of writing (with name, anonymous)
The arguments object, arguments is an array name for the passed parameter, Arguments[0] represents the first argument, 1 indicates the second, and so on
function (slightly) closure, referencing global variables

BOM Object

Window:alert (hint info), Prompt (Popup input box), confirm (confirmation message), setinterval (function, time)
Infinite execution, clearinterval (timer name), SetTimeout (function, time) only executes once, cleartimeout (timer name)
History:go (parameter)-1 means previous page, 1 means next page, back () Return to previous page, forward () return to next page
location:href= "URL Address"

Event
OnSubmit () This event must be written in the Form tab, must have a return value, confirm that the button is clicked
OnLoad () This event can only be written once, and placed in the body tag, a page or an image to complete loading.

 <HTML>        <Head>        <Scripttype= "Text/javascript">        functionload () {alert ("Page is loaded")        }        </Script>        </Head>                <Bodyonload= "load ()">        </Body>                </HTML>


Other events are placed where the element is to be manipulated (Onclick,onfocus (get Focus), onblur (loses focus))

Dom Object

Get element:
document.getElementById ("id")
Gets the value inside the element:
document.getElementById ("id"). Value

Output to page: alert ();
Write content to Browser: document.write ("")
Writes to the page at the specified location, InnerHTML

Basic Introduction to JavaScript knowledge

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.