JavaScript (Introductory article)

Source: Internet
Author: User

First, why do you want to learn JavaScript?

1, because you have no choice! Only JavaScript can control all common browsers, and JavaScript is one of the most important programming languages in the world, and learning Web technology must learn JavaScript.

Second, the JavaScript language features:

1. Scripting language

2. Object-based language

3. Simplicity

4. Dynamic Nature

5. Security

6. Cross-platform

Iii. introduction of JavaScript language

1, Embedded type:

1 <! DOCTYPE html> 2  3      4         <meta charset= "UTF-8" >  5         <title></title> 6         <script type= "Text/javascript" > 7          Alert (" This is the first JavaScript inline! "); 8         </script>  9           <body>     One </body> 

2, outer embedded type:

1 <! DOCTYPE html> 2  3      4         <meta charset= "UTF-8" >  5         <title></title> 6         <script src= "Jquery-3.1.1.js" ></script> 7       8     <body> 9     </body> 

Note: The first type of loading:

<script>...</script> logo into

Src:js path, you can use a relative path.

JS file execution is blocked, the browser will continue to execute the HTML document flow after execution.

Second load: You can place JavaScript identities in <body>, ... </body> bodies to create documents dynamically in order to implement certain parts.

Script Drop Location: The script tag can be defined anywhere in the HTML. But note the order in which the script and the document flow are executed.

Four, the Javascrip printing/output mode.

1. Print to page:

1 <! DOCTYPE html> 2  3      4         <meta charset= "UTF-8" >  5         <title></title> 6         <script> 7             document.write (' Print directly to page ' )  8         </script> 9          <body>  One     </body> 

2. Print to Controller

<! DOCTYPE html>            console.log (' Direct print to Controller ')        </script>    

3. Popup box

1 <! DOCTYPE html> 2  3      4         <meta charset= "UTF-8" >  5         <title></title> 6         <script> 7             alert (' Popup box ') 8         </script> 9          <body> one     </body>  

Javascrip identifier definition: identifier refers to the name of a variable, function, property, or parameter of a function

The first character of an identifier can be an underscore (_), dollar symbol ($), or a letter starting with a number.

Vi. basic elements of Javascrip language

1. Case-sensitive

2. Variable type not differentiated

3, the end of each statement can be omitted semicolon

4, the Code section to be closed

5. Note (a single line starts with//.) MultiRow start with/* and end with */)

Vii. ways to declare variables in the JavaScript language

1, the use of VAR (keyword) + variable name (identifier) in the way outside the function declaration, is a global variable, otherwise the function is declared a local variable.

Global variables

1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title></title>6<script>7             varA=12;8             functionarr () {9 alert (a)Ten} arr ()//pop Up One</script> A -<body> -</body> the

Local variables

<! DOCTYPE html>var a=12;             function arr () {                var b=2                alert (b)            } arr ()// popup 2        </script>    

Today, if you want to know more, please click on the attention, thank you

JavaScript (Introductory 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.