JavaScript (basic syntax)

Source: Internet
Author: User
Tags array definition


[Html]

 

This blog is a basic understanding of js. For those who do not have the js Foundation, it should be a basic introduction.
 

Javascript
It is a prototype inherited object-oriented dynamic type case-sensitive client script language. The main purpose is to solve the server language and provide a smoother browsing effect for the client.

Client scripting language with both object and event-driven and relatively secure

It is also a widely used scripting language for client web development. It is often used to add dynamic functions to Html webpages. For example, various operations of the corresponding user are used for form verification.

 

JavaScript framework
<Scripttype = "text/javascript" effecate = "javascript">

 

</Script>


Where

Language is used to support old browsers and Low-version platforms. type is the current method,

 

First, let's take a look at several basic functions.


Function:

It is a collection of code, encapsulated, and can be called directly. This is for students who have learned a programming language.

 


 

Alter function. The dialog box is displayed.

Prompt ("Enter data", "default") input box function


Next let's look at an instance.

Instance code


[Html]
<Head>
<Metahttp-equivmetahttp-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> operator </title>
</Head>
<Body>
</Body>
</Html>
<Scripttypescripttype = "text/javascript" effecate = "javascript">
Function inputdate (){
Prompt ("enter your password", "default ");
}
</Script>

<Head>
<Metahttp-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> operator </title>
</Head>
<Body>
</Body>
</Html>
<Scripttype = "text/javascript" effecate = "javascript">
Function inputdate (){
Prompt ("enter your password", "default ");
}
</Script>
The output is shown below:

 



 

Three cycle Structures
 

Sequence
Select
Loop

 

The above three loops are basically the same in all languages.

Then we can compare our previous VB Learning

 

 

 

 

 

 


The basic control statements are identical, which avoids repeated knowledge.

Some new knowledge is our focus.

 


Note:

 

In the Basic Data Type

Single quotation marks and double quotation marks are acceptable.

However, be sure to use the same

 

 

The array definition here is different from vb, but the definitions of vb.net and C # are quite different.

The variable definition here uses Var

If you define an array a, you can write it like this.

 


Var a = new Array (); indicates creating another object. Because everything is an object,

Objects have attributes and methods.

An important attribute is Length, which is used to obtain the number of arrays.

 

Note the sort method of the array here,


Returns an Array object whose elements have been sorted.


[Html]
<SPAN style = "FONT-SIZE: 18px"> the following example shows how to use the sort method:
FunctionSortDemo (){
Var a, l; // declare the variable.
A = new Array ("X", "y", "d", "Z", "v", "m", "r ");
L = a. sort (); // sort the array.
Return (l); // return the sorted array.
}
</SPAN>

The following example illustrates the usage of the sort method:
FunctionSortDemo (){
Var a, l; // declare the variable.
A = new Array ("X", "y", "d", "Z", "v", "m", "r ");
L = a. sort (); // sort the array.
Return (l); // return the sorted array.
}
 

 

The following is an example of the length attribute of the array.


[Html]
All arrays have some attributes.
The subscript starts from 0.
 
Check the instance code.
Var a = new Array ();
A [0] = "Send spot shares ";
A [1] = "Send spot shares ";
A [2] = "three ";
For (vari = 0; I <a. length; I ++ ){

Alert (a [I]);
}

Output data in each array one by one

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.