Basic JavaScript syntax and integrated development tool (IDE)

Source: Internet
Author: User
Tags netbeans

Javascript is the most common client scripting language in web design. It makes your webpage more lively and has functions such as displaying time and making special effects. Jquery, extjs, and Ajax are also based on JavaScript technologies.

Let's first introduce several JavaScript integrated development environments (IDE ),

I. Javascript plug-in jsdt in eclipse

Jsdt (JavaScript debug Toolkit) is an Eclipse plug-in for JavaScript editing and debugging. It is used to debug JavaScript. Jsdt supports cross-browser debugging and supports debugging Javascript in mainstream browsers such as IE, Firefox, Safari, and chrome. Jsdt supports setting breakpoints, single-step debugging, and other basic features of debugging tools.

1jsdt installation:

Open eclipse and select "Help \ eclipse marketpaces ..."

Enter jsdt in "find" to search for all marks.


Figure 1

Select JavaScript debug toolkit in the search result and click "Learn More" on the right"

Click the green downloading arrow (for example) on the right to obtain the link.

Figure 2 download link Figure 3

Set the address to "http: // jsdt ...... "Copy and download, and then open" Help \ install new software... ", t to add a new available repository, and paste the copied file in location.

Figure 4

Click "OK" to go to the next step and enter the download status. After several minutes, the installation program will be automatically installed.

Figure 5

After the installation is complete, you can create a project and edit the JavaScript code.

2. Create a project and edit JavaScript code

(1) Select "New \ others \ JavaScript Project", enter the project name, and then click Next. The new project is created.

(2) Right-click the project name, select "New \ JavaScript source file", enter the file name, and create a ". js" file. Next we will test the code and experience its powerful functions!

3 encoding Test

Test. js

/** *  */function f(){document.writeln("Hello World");window.alert("Hello JSDT!");}

Test.html

Use eclipse's web browser to open and view the test structure.

Through the above test, you will find that when you enter document or window, it will automatically prompt all methods included in document or window object. you do not need to enter the method name yourself. When you delete the braces "{or}" on one side, an error is returned. Can this improve efficiency and reduce errors.

Ii. netbeans
Netbeans is another useful JavaScript editing and debugging tool.

Download a netbeans from the Internet. The latest version is like netbeans7.2. Here is a link to download netbeans: Thunder: // token =

Create a project, such as a netbeans project, and create a Javascript file. Select File \ new file \ other \ JavaScript files, and click Next to complete.

Perform the encoding test like step 3 above to see the effect. The prompt function seems to be more powerful than jsdt.

III. Basic JavaScript Syntax 1 Basic Data Types

Javascript has six basic data types:

The six basic data types of JavaScript are undefined, number, Boolean, String, object, and function.

Undefined: After a variable is created, the variable has not been assigned a value previously. For example, var;

Number: Number is a numerical value type, which has two types of integer and real type;

Boolean: It is the correct and wrong values of the class, which can be true or false;

String: Single or double quotation marks are used to describe strings;

Object: Object data type such as f = new string ("this is a string! ");

Function: A function is a reference type and can be considered as a subclass of an object;

In JavaScript, VaR can be used for variable definition. The syntax is loose and not as rigorous as Java. For example:

VaR A = 12; A = 12; both methods are acceptable; string definition B = "test"; var B = 'test'; both methods are acceptable; familiar with Java can be written as int A = 12; string S1 = "test1"; or string S2 = new string ("Test2"); this is all incorrect.

The following are examples of data types:

Function datatype () {var A = 123; B = 125.89; C = true; var d = NULL; var E; F = new string ("this is a string! "); G = 'test2'; H =" test3 "; document. writeln ("integer" + A + "<br>"); document. writeln ("real" + B + "<br>"); document. writeln ("Boolean" + C + "<br>"); document. writeln ("null type" + D + "<br>"); document. writeln ("undefined type" + E + "<br>"); document. writeln ("string 1" + F + "<br>"); document. writeln ("string 2" + G + "<br>"); document. writeln ("string 3" + H + "<br> ");}

2 Function

Syntax:

Function Name (parameter list ){

Function body

Return a value or expression; // return can be omitted and added as needed

}

For example:

// Eg1: function funct1 () {document. writeln ("function 1 <br>");} // eg2: function funct2 () {document. writeln ("function 2 <br>"); var A = 10; B = 15.5; Return A + B;} // eg3: function funct3 (a, B) {document. write ("maximum value:"); Return A> B? A: B ;}

If the preceding examples are written in test. JS, the HTML file that calls the JavaScript method is as follows:

Test.html

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.