Getting started with JavaScript

Source: Internet
Author: User

JavascriptGetting started

 

JavascriptCause

InWebEarly stages of development,HtmlDefines most of the text documents and instructs the user agent to display them. HoweverHtmlThere is a disadvantage, that is, its status remains unchanged. If you want to change something or use user input data, you need to make a round-trip request to the server. Therefore, we need something more flexible: permission requiredWebDevelopers quickly report user information and do not reload the page from the server to changeHtml.

 

JavascriptWhat is

JavascriptPredecessor:Livescript,Later, Wangjing changed its nameJavascript,JavaThere is no necessary link between them.JavascriptIt is a client scripting language based on objects and events and with relative security. It is also a widely used ClientWebThe developed scripting language is often usedHtmlAdd dynamic functions to webpages, such as responding to various user operations.

 

JavascriptProblems and values

AboutJavascriptThe biggest feature is that once you learn to edit and use it in a browser, you can apply it. But in other fields, many large companies provideJavascriptComposed of objects and MethodsAPI(Application Programming Interface ),Goolge
MapsIs one of them. Just a few linesCodeYou can provide a zoom-and-scroll map on your website.

 

 

JavascriptBasic syntax

 

Statement

JavascriptProgramIs composed of several statements, the statement is writtenProgram. Javascript provides complete basic programmingStatement, They are:

Assignment Statement, switch selection statement, while loop statement, for loop statement, for each loop statement, do... while loop statement, break loop stop statement, continue loop interrupt statement, with statement, try... Catch and if statements (if... else, if... Else if ...).

Function

1) The function is defined by the function keyword (it can also be constructed by the function constructor)

2) A function defined by the function keyword can be called anywhere in a single scope (including before defining a function statement). A function defined by the VaR keyword can be called only after being defined.

3) The function name is referenced when the function is called. It is case sensitive and cannot be written incorrectly when the function is called.

4) The parameter indicates the value passed to the function for use or operation. It can be a constant, a variable, or a function, in a function, you can use the arguments object (the arguments object is a pseudo array, and the callee attribute references the called function) to access all parameters.

5) The return statement is used to return the value of the expression.

6) The yield statement throws an expression and interrupts function execution until the next call.

Common functions are in the following format:

Function myfunction (Params ){

// Executed statement

}

Function expression:

VaR myfunction = function (Params ){

// Executed statement

}

VaR myfunction = function (){

// Executed statement

}

Myfunction (); // call a function

Anonymous function, which is often used as a parameter to be passed among other functions:

Window. addeventlistener ('load', function (){

// Executed statement

}, False );

 

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.