JavaScript language basics 4: javascript language basics

Source: Internet
Author: User
Tags html comment

JavaScript language basics 4: javascript language basics

Let's talk about the variables in JavaScript.

The benefit of using variables in JavaScript: variables are stored in computer memory, and variables are very suitable for saving temporary data. variables only have a limited lifetime. When

When a user closes a page or opens a new page, the variable is released.

In JavaScript code, variable names are case-sensitive. In addition, some specific words or characters cannot be used as variable names. These specific words are in JavaScript.

Such as var and with. Some special characters cannot be used in variable names, such as & and percent. Number of JavaScript variable names

But the number cannot start with the variable name.


Invalid variable names are listed below:

Var // Reserved Words in JavaScript

Start with 12AD // number

H & dg // contain & characters

H % ji // contains % characters

<span style="font-size:14px;"></span>

Some valid variable names are listed below:

Helloworld23

Hello_world

When defining variables, we should use standard names for naming, such as declaring names:

Var name;

Next let's take a look at the instance code:

<span style="font-size:14px;"><HTML><HEAD><TITLE>Hello World</TITLE></HEAD><BODY BGCOLOR="WHITE"><SCRIPT Language="JavaScript" TYPE="text/javascript">var myName;myName="BillGu";alert(myName);myName=1234;alert(myName);</SCRIPT></BODY></HTML></span>

When the browser loads the file, a message box is displayed (alert is the message box ):

In the message box, the variable myName is BillGu.

At the beginning, no value was assigned for myName. In this case, the initial value of myName is undefined, myName is assigned to BillGu, and alert is called in the form of a message box.

Show. When you click OK, another message box is displayed:




In the message box, we can see that 1234 is displayed.

If you assign a value to myName again, the original value of the variable will be lost. In JavaScript, there is a variable calledGarbage collection processWill be performed automatically

Release memory that is not in use. When JavaScript detects that a variable is not in use, or the variable that references an object is assigned a new

To release the memory space occupied by the variables.




Reprinted please indicate the source: http://blog.csdn.net/hai_qing_xu_kong/article/details/40760675 sentiment control _ click to open the link




What is the basic language of javascript? What language is the basic language of aspnet ??

Many people have such misunderstandings about JavaScript as derived from the Java language. In fact, JavaScript is an independent Web Page scripting language. It has nothing to do with Java, but it is just similar in syntax. Javascript is used regardless of asp.net, Jsp, PHP, or asp. The biggest difference between JavaScript and C #, Java, and other programming languages is to execute and compile the code first. That is to say, the JavaScript script will be downloaded to the user's computer as the web page, and then loaded to the browser, the JavaScript script is compiled only when the corresponding event is triggered. This is completely different from that of the Java or C # language on any server.

For your convenience, I will give you an example. For example, if you do not enter a required field on the user registration page, or the entered content is invalid (for example, if the QQ number is written as "abc"), the browser will give you a prompt to correct the error. This is the role of JavaScript, it reduces the load on the server and accelerates user experience. Therefore, JavaScript is an important part of a website.

Ps: JavaScript can also be used for some special effects. There are a lot of code on the Internet. You can check it out.

Asp.net is based on C # and is now a popular language like Java. It is favored by many enterprises because of its great advantages in rapid development. However, Microsoft is not as selfless as Java. To keep its dominant position in Windows, Microsoft. net platform (including ASP.. NET Security is indeed a headache. Of course, if your website does not have high security requirements, ASP. NET is a very good choice.

Speaking of learning, I suggest you study both C # and JavaScript, because these two languages and the Java language in Jsp are similar in syntax structure, as long as you have learned one, others will be easy to understand. However, do not think it will be very simple, because as a developer, it will always be a rookie in front of these languages. Only by tirelessly absorbing new knowledge can you ensure that you are ahead of others.

I have said so much, hoping to help you, and wish you success! Thank you!

Javascript Language

The answer is correct.
I would like to add:

It looks like this: <! -- Omitted in the middle // -->
As for why, let me say this.

<! -- This is an HTML comment -->
// This is a javascript annotation.

The effect of these two operations is that some browsers previously did not support JavaScript. Therefore, when you encounter a browser that does not support JavaScript, the JavaScript code will be treated as "HTML comments" and there will be no error in the script. If the browser supports JavaScript. Then // takes effect. In this format: // -->, where --> is commented out. So the JavaScript function is used!

In addition, JavaScript has another annotation method.

/*
Multi-line comment example
/*
Nested comment
*/
*/

// Comment the first line
// Comment the second line
Reference: tieba.baidu.com/f? Kw = javascript

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.