JavaScript Variables Basics _ Basics

Source: Internet
Author: User

1. Case sensitive

<script language= ' JavaScript ' >

var name= "Zhang";

var name= "ZHANG";

Document.writeln (name+ "<br/>");

document.write (name);

</script>

2. Weakly typed variables

All variables are marked with the VAR keyword, and the JavaScript interpreter automatically assigns

3. The end part of the sentence is optional

such as : Var name=23; or var name=23 can be

<script language= ' JavaScript ' >

var name= "Zhang"

var name= "ZHANG"

Document.writeln (name+ "<br/>")

document.write (name)

</script>

4. Code can be embedded in HTML or JS files can be introduced

<title>

Javascript

</title>

<script language= ' javascript ' >/* embedded in code, usually in head

var name= "Zhang"

var name= "ZHANG"

Document.writeln (name+ "<br/>")

document.write (name)

</script>

<body style= "Background-color: #dff" >

</body>

4.1 Code can be imported directly from another file

such as: <script src= "Javascript.js" ></script> results are the same

5. Multiple variables can be declared at the same time

such as: Var name= "Jerryzhang", age=23,sex= "male";

document.write (name+ "<br/>" +sex+ "<br/>" +age);

6. can not initialize

such as : var name;

document.write (name);

7 variable definitions cannot use keywords or reserved words (note: I do not know what to reserve words)

Such as: Html,title,history can be, but the document is not;

such as : var html= "asp.net";

document.write (HTML);

A variable in 8.JavaScript can store multiple types of variables

such as: Var i=23;

document.write (i+ "<br/>");

I= "Jerryzhang";

document.write (i+ "<br/>");

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.